Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample java can not start by Missing environment variable DB_NAME #532

Open
hanchenglin opened this issue Nov 29, 2023 · 3 comments
Open
Labels
admin-ui Admin web application sample-application Sample application

Comments

@hanchenglin
Copy link

Sample java can not start by Missing environment variable DB_NAME

How to fix jdbc config error

Error log:

2023-11-30T01:31:12.294+09:00 2023-11-29 16:31:12.293 ERROR 7 --- [ main] o.s.boot.SpringApplication : Application run failed

2023-11-30T01:31:12.294+09:00

Copy
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderDaoImpl': Unsatisfied dependency expressed through field 'jdbc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getDataSource' defined in class path resource [com/amazon/aws/partners/saasfactory/configuration/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'getDataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing environment variable DB_NAME
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderDaoImpl': Unsatisfied dependency expressed through field 'jdbc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getDataSource' defined in class path resource [com/amazon/aws/partners/saasfactory/configuration/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'getDataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing environment variable DB_NAME

Environment

  • AWS SaaS Boost Version: 2.2.3

Other information

I configed Postgres, also auto created database.
I can not see where set env in https://github.com/awslabs/aws-saas-boost/blob/main/samples/java/Dockerfile

But sample java need env in https://github.com/awslabs/aws-saas-boost/blob/main/samples/java/src/main/java/com/amazon/aws/partners/saasfactory/configuration/DataSourceConfig.java#L35

    private static final String DB_NAME = System.getenv("DB_NAME");
    private static final String DB_HOST = System.getenv("DB_HOST");
    private static final String DB_PORT = System.getenv("DB_PORT");
    private static final String DB_USER = System.getenv("DB_USER");
    private static final String DB_PASSORD = System.getenv("DB_PASSWORD");
@hanchenglin hanchenglin added the triage Needs categorization and prioritization label Nov 29, 2023
@hanchenglin
Copy link
Author

@hanchenglin
Copy link
Author

Sorry! I changed config can work now, but I think we shoud refactor item layout.
スクリーンショット 2023-12-01 0 27 15 1

@brtrvn brtrvn added admin-ui Admin web application sample-application Sample application and removed triage Needs categorization and prioritization labels Dec 5, 2023
@brtrvn
Copy link
Contributor

brtrvn commented Dec 5, 2023

See the instructions for Step 7 in the Getting Started guide. The database name is required for the sample app.

The database name is optional in the App Config form because a database name may not be required by your application (it may be hard coded in your app). Setting the database name in the App Config also triggers the RDS bootstrap Lambda during tenant onboarding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
admin-ui Admin web application sample-application Sample application
Projects
None yet
Development

No branches or pull requests

2 participants