2015-03-25 52 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