I am Trying to setup a very simple example based on the Spring Boot 2 Quick Start (the ping example). My plan is to take the example and extend it by using a JPA Model (existing) to retrrieve data from a Aurora DB (also existing) and expose the data to REST.
For developing I am using Eclipse with AWS Plugin to deploy to AWS (deploy serverless project).
change template.yml to serverless.template for being able to deploy with AWS Eclipse Plugin --> Works, indeed there is not much in there, it is only deploying a lambda and a API GW,
At this point everything is working fine, I can call the Ping URL and everything works as expected.
Next Step is the one where things stop working.
Add these 2 dependencies to pom:
Additionally I need to tell the lambda where the DB is. I am using Env variables for that, and I have a application.properties under the src/main/resources folder. I have added these lines there (only a logging entry was there).
for debugging I also tried to put the real values there, but no difference.
What now happen is following:
Running Spring Boot as Local Application works fine (Added a public CommandLineRunner demo() in the Application class). In log I can see Hikari Logs which seems perfectly fine, so it looks also connection to Db locally is working fine. No Errors at all.
If I deploy it (either deploy serverless project, or also package shade:shade and manually upload the JAR into the AWS Console Lambda) I keep getting this below whatever I put in application.properties. I get the feeling that someway the Lambda is not using the application.properties.
The rest of the code is unchanged, I have not yet added any JPA entities, other Controllers or Repositories (which is what I plan next). Also for testing I am still trying to call the ping.
2020-05-26T14:08:10.318+02:00
APPLICATION FAILED TO START
2020-05-26T14:08:10.318+02:00
Description:
2020-05-26T14:08:10.318+02:00
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
2020-05-26T14:08:10.318+02:00
Reason: Failed to determine a suitable driver class
2020-05-26T14:08:10.318+02:00
Action:
2020-05-26T14:08:10.318+02:00
Consider the following:
2020-05-26T14:08:10.318+02:00
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
2020-05-26T14:08:10.318+02:00
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Sorry this is maybe a very stupid questions for the experts, but I am new to Spring. It would be really great if there would be a full working skeleton example with using JPA entities connecting to an existing DB and exposing via REST.
Thanks a lot!
manuel
Expected behavior
Connect to DB using JPA and expose Data via REST.
Actual behavior
Getting Failed to configure a DataSource: 'url' attribute is not specified
Hi,
closing this as I got it working.
Some findings:
Moved away from Spring Boot and switched to Spring Cloud functions.
The Eclipse AWS Plugin seems not to be working fine with Spring applications (both boot and cloud functions, works fine with plain java). If I do a deploy serverless project ( BTW, is there any documentation what exactly it is doing there with the lambda java code? How is it packaging? how is it deploying? Which maven commands?), it was never ever working (seems it was missing/ not finding application.properties which is where the DB connection parameters where defined and after I fixed that I was keeping getting errors over errors). But doing a maven clean package and manually uploading the packaged JAR works perfectly (but still annoying).
Cold starts with both Spring are out-of-the-box definitely slower than a plain java code. Package size also is roughly 4 times bigger for similar capabilities.
If you run with Spring Cloud Functions be careful to choose the right handler there and also the right input/output classes.
Bye
manuel
Scenario
I am Trying to setup a very simple example based on the Spring Boot 2 Quick Start (the ping example). My plan is to take the example and extend it by using a JPA Model (existing) to retrrieve data from a Aurora DB (also existing) and expose the data to REST. For developing I am using Eclipse with AWS Plugin to deploy to AWS (deploy serverless project).
Following steps I have so far executed: Generate Project with mvn archetype:generate as explained in the quick start (https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot2) --> Works
change template.yml to serverless.template for being able to deploy with AWS Eclipse Plugin --> Works, indeed there is not much in there, it is only deploying a lambda and a API GW,
At this point everything is working fine, I can call the Ping URL and everything works as expected.
Next Step is the one where things stop working. Add these 2 dependencies to pom:
Additionally I need to tell the lambda where the DB is. I am using Env variables for that, and I have a application.properties under the src/main/resources folder. I have added these lines there (only a logging entry was there).
for debugging I also tried to put the real values there, but no difference. What now happen is following:
The rest of the code is unchanged, I have not yet added any JPA entities, other Controllers or Repositories (which is what I plan next). Also for testing I am still trying to call the ping.
2020-05-26T14:08:10.318+02:00 APPLICATION FAILED TO START
2020-05-26T14:08:10.318+02:00 Description:
2020-05-26T14:08:10.318+02:00 Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
2020-05-26T14:08:10.318+02:00 Reason: Failed to determine a suitable driver class
2020-05-26T14:08:10.318+02:00 Action:
2020-05-26T14:08:10.318+02:00 Consider the following:
2020-05-26T14:08:10.318+02:00 If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
2020-05-26T14:08:10.318+02:00 If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Sorry this is maybe a very stupid questions for the experts, but I am new to Spring. It would be really great if there would be a full working skeleton example with using JPA entities connecting to an existing DB and exposing via REST. Thanks a lot! manuel
Expected behavior
Connect to DB using JPA and expose Data via REST.
Actual behavior
Getting Failed to configure a DataSource: 'url' attribute is not specified
Steps to reproduce
see above
Full log output
see above