Overview
We use a JNDI data source in our custom adapter, but the BizLogic execution is failing to locate the data source and throwing a javax.naming.NameNotFoundException exception.
Example:
Caused by: javax.naming.NameNotFoundException: Name [jdbc/CLMDBXA] is not bound in this Context. Unable to find [jdbc].
Below error is reported in the BizLogic log:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clmDataSourceXA' defined in class path resource [applicationContext-dao.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/CLMDBXA] is not bound in this Context. Unable to find [jdbc].
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1572)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
... 72 more
Caused by: javax.naming.NameNotFoundException: Name [jdbc/CLMDBXA] is not bound in this Context. Unable to find [jdbc].
at org.apache.naming.NamingContext.lookup(NamingContext.java:816)
at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:163)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:231)
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:217)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1631)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)
Below are the configuration of datasource( $SBM_HOME\tomee\ejbServer\conf\tomee.xml):
<Container id="EJBJmsMdbContainer" ctype="MESSAGE">
ResourceAdapter = EJBJmsResourceAdapter
</Container>
<Resource id="jdbc/CLMDB" type="javax.sql.DataSource">
JdbcDriver = org.postgresql.Driver
JdbcUrl = jdbc:postgresql://localhost/cxprocess
Username = cxprocess
Password = cxprocess
MaxIdle = 30
</Resource>
<Resource id="jdbc/CLMDBXA" type="javax.sql.DataSource">
JdbcDriver = org.postgresql.Driver
JdbcUrl = jdbc:postgresql://localhost/cxprocess
Username = cxprocess
Password = cxprocess
MaxIdle = 30
</Resource>
$SBM_HOME\tomee\ejbServer\conf\web.xml:
<resource-ref>
<res-ref-name>java:jdbc/CLMDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<lookup-name>java:openejb/Resource/jdbc/CLMDB</lookup-name>
</resource-ref>
<resource-ref>
<res-ref-name>java:jdbc/CLMDBXA</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<lookup-name>java:openejb/Resource/jdbc/CLMDBXA</lookup-name>
</resource-ref>
Environment
Savvion-Bizlogic 10.0.18+ Os: Windows App Server: Tomcat Database: postgres 9.5
Solution
This particular issue happens because the data source names used in the two configuration files do not match. Eg: jdbc/CLMDB vs java:jdbc/CLMDB. The same data source names should be used in both configuration files (tomee.xml and web.xml).
In general, this issue happens when the data source is not initialized due to incorrect syntax or data source properties.
To confirm your data source settings, check the EJB Server log file to ensure that the JDBC Datasource is correctly initialized during start up.
When creating a new datasource, the "jdbc/BizLogic" data source available in the $SBM_HOME\tomee\ejbServer\conf\tomee.xml file can be used as an example.
Note: This issue is not an Aurea Process-related issue because it is related to configuring a JDBC Datasource in Tomee (tomee.xml), and referencing it (using it) in EJBServer/BizLogic (that is running within Tomee).