java.lang.NoClassDefFoundError:org / hibernate / cache / RegionFactory

时间:2015-08-05 15:11:25

标签: java hibernate

我的应用程序中出现此错误,使用Hibernate 3.0创建(我只能使用此版本)

  

org.eclipse.jetty.servlet.ServletHolder $ 1:
  org.springframework.beans.factory.BeanCreationException:
  创建名为'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0'的bean时出错:
  调用init方法失败;嵌套异常是
  java.lang.NoClassDefFoundError:org / hibernate / cache / RegionFactory

调度-servlet.xml中:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<mvc:annotation-driven/>

<context:annotation-config />

<context:component-scan base-package="com.company"/>

<mvc:default-servlet-handler/>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/pages/"/>
    <property name="suffix" value=".jsp"/>
</bean>

<bean name="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="configLocation">
        <value>classpath:hibernate.cfg.xml</value>
    </property>
</bean>

hibernate.cfg.xml中:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="factory">
    <property name="connection.datasource">java:comp/env/jdbc/TestDB</property>
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.use_sql_comments">true</property>
    <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
    <mapping class="com.company.model.Organization" />
</session-factory>

我该如何解决?它似乎可以通过升级到Hibernate 4来解决,但我需要Hibernate 3.0。

1 个答案:

答案 0 :(得分:0)

org.hibernate.cache.RegionFactory可从Hibernate 3.3开始使用。您需要从路径中删除旧版本的Hibernate jar文件并使用较新版本。如果您使用的是Maven或ivy等组件管理器,只需删除依赖项并将其替换为较新的版本。