Why JBoss Fuse can not find DataSource ?
Issue
- While trying to deploy a bundle with the application using a datasource on JBoss Fuse, it throws Error.
- This application's code correctly runs on Jboss Fuse Service Works.
- Following is the configuration used to deploy the datasource. Put a file named
"test-ds.karaf.xml"in the hot deployment directory. Following is the content of this file:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="dataSource" class="org.postgresql.ds.PGPoolingDataSource" destroy-method="close">
<property name="serverName" value="localhost:5432/test"/>
<property name="user" value="testUSER"/>
<property name="password" value="testPWD"/>
<property name="dataSourceName" value="testDS"/>
<property name="initialConnections" value="2"/>
<property name="maxConnections" value="4"/>
</bean>
<service interface="javax.sql.DataSource" ref="dataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="testDS"/>
</service-properties>
</service>
</blueprint>
- The bundle of the Postgresql driver are already installed:
[ 327] [Active ] [ ] [ ] [ 60] PostgreSQL JDBC Driver OSGi bundle (9.1.901.jdbc4_1)
[ 340] [Active ] [Created ] [ ] [ 60] test-ds.karaf.xml (0.0.0)
- The problem is that the bundle application raises the following error:
Caused by: org.hibernate.HibernateException: Could not find datasource
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:79)[341:test-backend-camel-5.2.0.war:0 ]
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)[341:test-backend-camel-5.2.0.war:0 ]
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)[341:test-backend-camel-5.2.0.war:0 ]
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:438)[341:test-backend-camel-5.2.0.war:0 ]
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:91)[341:test-backend-camel-5.2.0.war:0 ]
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)[341:test-backend-camel-5.2.0.war:0 ]
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)[341:test-backend-camel-5.2.0.war:0 ]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)[341:test-backend-camel-5.2.0.war:0 ]
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)[341:test-backend-camel-5.2.0.war:0 ]
at test.database.util.AbstractHibernateUtil.init(AbstractHibernateUtil.java:129)[341:test-backend-camel-5.2.0.war:0 ]
... 39 more
Caused by: javax.naming.NameNotFoundException; remaining name 'testDS'
at org.eclipse.jetty.jndi.local.localContextRoot.lookup(localContextRoot.java:490)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
at org.eclipse.jetty.jndi.local.localContextRoot.lookup(localContextRoot.java:536)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)[338:org.apache.aries.jndi.core:1.0.0]
at javax.naming.InitialContext.lookup(InitialContext.java:392)[:1.6.0_38]
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)[341:test-backend-camel-5.2.0.war:0 ]
- Users cannot check the jndi names of datasources through the command
"jndi:names"because it does not works as reported here https://issues.jboss.org/browse/ENTESB-2193. - How to solve this issue ?
Environment
- Red Hat JBoss Fuse
- 6.1.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
