日期:2014-05-18  浏览次数:20802 次

Spring + OpenJpa 错误,菜鸟求助!!
最近做的项目需要用JPA做统一数据层
我用的JPA实现是Apache的OpenJPA, 在跟Spring结合使用的时候出现了个很低级的问题(求别喷),报错如下
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/classes/application-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/persistence/PersistenceException
.
.
.
.
Caused by: java.lang.NoClassDefFoundError: javax/persistence/PersistenceException

按报错信息应该是找不到类javax.persistence.PersistenceException, 可我引入的JPA包里有这个类的
引入的JPA包有:
-openjpa-1.2.3.jar
-geronimo-jpa_1.0_spec-1.1.2.jar
Spring的版本是2.5.6

spring配置信息如下:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${mesportal.jdbc.driverClassName}" />
        <property name="url" value="${mesportal.jdbc.url}" />
        <property name="username" value="${mesportal.jdbc.username}" />
        <property name="password" value="${mesportal.jdbc.password" />
    </bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
                <property name="showSql" value="true" />
                <property name="generateDdl" value="true" />
                <property name="databasePlatform" value="org.apache.openjpa.jdbc.sql.PostgresDictionary" />
            </bean>
        </property>
        <property name="loadTimeWeaver">
            <bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" />
        </property&