I am trying to deploy an example CUBA app with postgresql to Pivotals Cloud Foundry Platform.
I’ve followed the blog post provided by Mario.
Generally speaking, it is working. However, I have to hard-code the DBaaS credentials.
What I am looking for is a way to differentiate between local development setup where the database may be linked locally and the database connection, which should be resolved dynamically by using the spring cloud foundry connector library.
Steps to reproduce:
- enter credentials for local development database in the project properties via CUBA Studio
- create deployment descriptor with the single war file option (custom war-context.xml with DBaaS credentials and single-web-war.xml files)
- tried to remove the Resource tag from the war-context.xml, didn’t make a difference
- use dependecy injection via spring xml configuration in spring.xml (see the blog post)
I’ve also tried to use the Java-based approach for configuring the data source, neither this nor the xml config succeeded.
I’m getting following error:
2018-01-25T09:02:28.926+01:00 [APP/PROC/WEB/0] [OUT] org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [cuba-spring.xml]: Cannot resolve reference to bean ‘cubaDataSource’ while setting bean property ‘dataSource’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘cubaDataSource’ defined in class path resource [cuba-spring.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/CubaDS] is not bound in this Context. Unable to find [jdbc].
As it seems, the app is trying to find the jndi datasource before my custom configuration code is invoked and is therefore failing.
Are there any steps I can take to fix the issue?
You can find an example project attached.cf-database-test.zip (73.4 KB)
Your help is much appreciated.
Thanks for the great framework!