将spring3+hibernate J2EE应用程序部署到JBoss 6时找不到jndi数据源
我有一个使用 Spring 3.0 + 最新版本的 Hibernate (3.6) 的 J2EE 应用程序,我想将其部署在 JBoss 6 CR1 上。
但我遇到了一个异常,指出在部署应用程序时找不到数据源。
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
我检查了JBoss应用服务器的JMX控制台,我在Spring中声明的数据源位于java命名空间下。
我在 application-context.xml 中将数据源定义为
<jee:jndi-lookup id="dataSource" jndi-name="java:ThisIsMyDataSource"/>
在 persistence.xml 文件中声明:
<persistence-unit name="persistenceUnit" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/ThisIsMyDataSource</jta-data-source>
</persistence-unit>
名称为 ThisIsMyDataSource 的数据源位于 /jboss/server/default/deploy 的部署文件夹中
看起来我的应用程序正在尝试查找javax.sql.datasource 的 bean 自动装配到其他一些类的构造函数中,但失败了。
有谁知道如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是一个错字。你可以尝试用
而不是
It seems like a typo. Can you try with
instead of