2015-03-25 54 views
1

我想建立一個Spring MVC + Hibernate WAR部署到Jboss 7.1.1 Final。我的應用程序使用Hibernate 3.6.1 &到目前爲止,我的理解是Hibernate 4與AS一起打包,並且是默認的持久性提供程序。我沒有使用persistent.xml文件配置。如何用Jboss7設置hibernate3?

我已經提供了所有必需的java,但我仍然遇到以下異常,任何人都可以幫助我設置JBoss中的hibernate 3相關更改嗎?

03:14,597 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-3) 
Context initialization failed: 
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'hibernateVendor' defined in ServletContext resource [/WEB-INF/hibernate-context.xml]: 
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Could not instantiate bean class [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: 
Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/ejb/HibernatePersistence 
+0

您使用的是jboss-deployment-structure.xml嗎? – 2015-03-25 09:08:46

+0

不,我試圖在這個路徑上手動設置hibernate 3的相關配置:AS/modules/org/hibernate/3並添加了所有需要的jar文件和創建的module.xml文件。我正走在正確的道路上嗎? – 2015-03-25 09:20:38

回答

1

既然你得到一個java.lang.NoClassDefFoundError(而不是一個ClassNotFoundException),它可能是某種形式的類加載問題。

嘗試添加將解決您的問題的hibernate-entitymanager依賴項。

<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-entitymanager</artifactId> 
    <version>${hibernate.version}</version> 
    <exclusions> 
     <exclusion> 
      <groupId>cglib</groupId> 
      <artifactId>cglib</artifactId> 
     </exclusion> 
     <exclusion> 
      <groupId>dom4j</groupId> 
      <artifactId>dom4j</artifactId> 
     </exclusion> 
    </exclusions> 
</dependency> 
+0

這對我有用。 – 2015-03-25 10:09:13