JBoss throws java.lang.ClassCastException org.jboss.resource.adapter.jdbc.WrapperDataSource cannot be cast to javax.sql.DataSource
Issue
- Using a EJB/WebService module which uses hibernate for DB access.
- The EJB module defines a DataSource with the below properties:
<jndi-name>jdbc/lslDbDataSource</jndi-name> <use-java-context>false</use-java-context>
- When the DS is deployed the JNDI name gets created on the Global JNDI name space as expected, but when Hibernate gets initialized it fails with the following error:
INFO [STDOUT] (http-10.232.11.11-8080-2) 11:18:00,947 FATAL [DatasourceConnectionProvider] Could not find datasource: jdbc/lslDbDataSource java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.WrapperDataSource cannot be cast to javax.sql.DataSource at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56) at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:397) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2006) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1289) at com.example.base.BaseRootDAO.initialize(BaseRootDAO.java:133)
Environment
- JBoss Enterprise Application Platform (EAP) 5.0.0.GA
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.
