Configuring oracle datasource in JBoss 6.0.0 CR1
newguy2010 Dec 16, 2010 12:04 AMI have a J2EE application which uses Spring 3.0.5 + latest version of Hibernate (3.6) and I want to deploy it on JBoss 6 CR1.
But I came across an exception stating that the jndi datasource is not found when I deployed the application.
Caused by: org.springframework.beans.factory.NoSuchBeanDefini tionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultL istableBeanFactory.raiseNoSuchBeanDefinitionExcept ion(DefaultListableBeanFactory.java:920) [:3.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultL istableBeanFactory.doResolveDependency(DefaultList ableBeanFactory.java:789) [:3.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultL istableBeanFactory.resolveDependency(DefaultListab leBeanFactory.java:703) [:3.0.5.RELEASE] at org.springframework.beans.factory.support.Construc torResolver.resolveAutowiredArgument(ConstructorRe solver.java:795) [:3.0.5.RELEASE] at org.springframework.beans.factory.support.Construc torResolver.createArgumentArray(ConstructorResolve r.java:723) [:3.0.5.RELEASE] ... 159 more |
I have checked the JMX console of JBoss Application Server and the datasource I declared in Spring is under java namespace.
I delcared the jndi datasource in my application-context.xml as
<jee:jndi-lookup id="dataSource" jndi-name="java:ThisIsMyDataSource"/> |
In persistence.xml file I declared:
<persistence-unit name="persistenceUnit" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence </provider> <jta-data-source>java:/ThisIsMyDataSource</jta-data-source> </persistence-unit> |
A datasource with a name called ThisIsMyDataSource is in the deploy folder of /jboss/server/default/deploy
<datasources>
<local-tx-datasource>
<jndi-name>ThisIsMyDataSource</jndi-name>
<connection-url>jdbc:oracle:thin:@localhost:1521:abc</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>abc</user-name>
<password>12345678</password>
<!--pooling parameters -->
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
</local-tx-datasource>
</datasources>
It looks like my application was trying to look for the bean for javax.sql.datasource to autowire into some other classes' constructors and failed.
Does anyone know how to resolve this?