JBoss Community

Configuring oracle datasource in JBoss 6.0.0 CR1

created by Sam Tsang in Datasource Configuration - View the full discussion

I have a J2EE application which uses Spring 3.0 + 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 datasource is not found when I deployed the application.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: 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.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920) [:3.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789) [:3.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703) [:3.0.5.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795) [:3.0.5.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.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 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

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?

Reply to this message by going to Community

Start a new discussion in Datasource Configuration at Community