JBOSS AS 7模块依赖于Spring + Hibernate项目

时间:2014-10-22 16:20:19

标签: spring hibernate jboss

Iam尝试将我的所有应用程序库配置为jboss作为模块依赖项。这是我的jboss-deployment-structure.xml文件以及spring和Hibernate文件夹中的相应jar。但是当我部署我的应用程序时,我得到以下错误请帮助。

Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accessDAOImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.lv.rs.accessautomation.dbaccess.impl.AccessDAOImpl.sessionFactory; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) [spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) [spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
	at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.lv.rs.accessautomation.dbaccess.impl.AccessDAOImpl.sessionFactory; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	... 21 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
	at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.7.0_07]
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404) [rt.jar:1.7.0_07]
	at java.lang.Class.getDeclaredConstructors(Class.java:1853) [rt.jar:1.7.0_07]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:230) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:930) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:903) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:735) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:666) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:518) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:319) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:185) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:833) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
	... 23 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException from [Module "org.springframework:main" from local module loader @642a590d (roots: /opt/LVjboss/current/modules)]
	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
	... 38 more

Inside org.springframework:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.springframework">
	<resources>
		<resource-root path="spring-aop-3.0.6.RELEASE.jar"/>
		<resource-root path="aopalliance-1.0.jar"/>
		<resource-root path="spring-asm-3.0.6.RELEASE.jar"/>
		<resource-root path="spring-beans-3.0.6.RELEASE.jar"/>
		<resource-root path="spring-context-3.0.6.RELEASE.jar"/>
		<resource-root path="spring-core-3.0.6.RELEASE.jar"/>
		<resource-root path="spring-context-support-3.0.6.RELEASE.jar"/>
		<resource-root path="spring-expression-3.0.6.RELEASE.jar"/>
		<resource-root path="spring-jdbc-3.0.6.RELEASE.jar"/>
		<resource-root path="spring-orm-3.0.6.RELEASE.jar"/>
		<resource-root path="spring-tx-3.0.6.RELEASE.jar"/>
		<resource-root path="spring-web-3.0.6.RELEASE.jar"/>
		<resource-root path="spring-webmvc-3.0.6.RELEASE.jar"/>
	</resources>
      <dependencies>  
	        <module name="javax.api"/> 
		<module name="org.aopalliance"/> 
	        <module name="javax.annotation.api"/>  
	        <module name="org.apache.commons.logging"/> 
		<module name="javax.enterprise.api" /> 
		<module name="javax.servlet.jsp.api" />
		<module name="javax.servlet.jstl.api" />
		<module name="org.jboss.vfs" />
		
      </dependencies>  
</module>


Hibernate:


<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2010, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<module xmlns="urn:jboss:module:1.1" name="org.hibernate.commons-annotations">
  <resources>
    <resource-root path="hibernate-commons-annotations-3.2.0.Final.jar"/>
      <resource-root path="hibernate-core-3.6.8.Final.jar"/>
        <resource-root path="hibernate-entitymanager-3.6.8.Final.jar"/>
	  <resource-root path="hibernate-jpa-2.0-api-1.0.1.Final.jar"/>
	    <resource-root path="hibernate-jpamodelgen-1.2.0.Final.jar"/>
	    <resource-root path="jta-1.1.jar"/>
        <!-- Insert resources here -->
  </resources>

  <dependencies>
    <module name="asm.asm"/>
    <module name="javax.api"/>
    <module name="javax.persistence.api"/>
    <module name="javax.transaction.api"/>
    <module name="javax.validation.api"/>
    <module name="org.antlr"/>
    <module name="org.apache.commons.collections"/>
    <module name="org.dom4j"/>
    <module name="org.infinispan" optional="true"/>
    <module name="org.javassist"/>
    <module name="org.jboss.as.jpa.hibernate" slot="3" optional="true"/>
    <module name="org.jboss.logging"/>
   <!-- <module name="org.hibernate.envers" services="import" optional="true"/> -->
    <module name="javax.xml.bind.api"/>
    <module name="org.jboss.logging"/>
    <module name="org.jboss.common-core"/>
    <module name="org.joda.time"/>
    <module name="org.slf4j"/>
    <module name="org.apache.xerces" services="import"/>
    <module name="sun.jdk" services="import"/>
  </dependencies>
</module>

<jboss-deployment-structure>
    <deployment>
    	<dependencies>
    		<module name="com.lv.ldap" />
    		<module name="com.lv.log4j.accessmgmt" />
    		<module name="com.lv.common.libraries" />
    	  	<module name="com.oracle.ojdbc6" />
    	 	<module name="org.springframework" />
    		<module name="org.slf4j" />
    		<module name="org.dom4j" />
    		<module name="org.antlr" />
    		<module name="org.javassist" />
    		<module name="org.apache.commons.collections" />
    		<module name="org.apache.commons.pool" /> 
    		<!-- <module name="org.hibernate" /> -->
    		<module name="org.hibernate.commons-annotations" />
    		<!-- <module name="org.hibernate.envers" /> -->
    		
    	</dependencies>
        <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
        <exclusions>
            <module name="org.apache.log4j" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

1 个答案:

答案 0 :(得分:0)

hibernate和spring需要以下库才能协同工作。

hibernate-commons-annotations-4.0.4.Final.jar
hibernate-core-4.3.5.Final.jar
antlr-2.7.7.jar
dom4j-1.6.1.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
jandex-1.1.0.Final.jar
javassist-3.18.1-GA.jar
jboss-logging-3.1.3.GA.jar
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar
postgresql-9.3-1102.jdbc3.jar
spring-aop-4.0.6.RELEASE.jar
spring-beans-4.0.6.RELEASE.jar
spring-context-4.0.6.RELEASE.jar
spring-core-4.0.6.RELEASE.jar
spring-expression-4.0.6.RELEASE.jar
spring-orm-4.0.6.RELEASE.jar
spring-tx-4.0.6.RELEASE.jar
spring-web-4.0.6.RELEASE.jar
spring-webmvc-4.0.6.RELEASE.jar
commons-logging-1.2.jar
aopalliance-1.0.jar
spring-aspects-4.0.6.RELEASE.jar
spring-jdbc-4.0.6.RELEASE.jar
org.springframework.test-2.5.6.A.jar
junit-dep-4.10.jar
spring-test-4.0.6.RELEASE.jar
log4j-api-2.0.2.jar
log4j-core-2.0.2.jar