JPA + eclipseLink2.0失败

在我的测试项目中,由于以下错误,Spring容器无法创建扩展JpaRepository的bean。

引起:org.springframework.beans.factory.BeanCreationException:创建名为'srSvcInfoMtrRepository'的bean时出错:FactoryBean在创建对象时抛出异常; 嵌套异常是java.lang.NoSuchMethodError: javax.persistence.EntityManager.getMetamodel()Ljavax / persistence / metamodel / Metamodel;

这可能是与JPA版本相关的问题。

我在persistence.xml中的eclipelink2.0(org.eclipse.persistence.jpa.PersistenceProvider)中指定了某个persistenceProvider。

你对这个问题有什么想法吗?

堆栈跟踪

2012-05-14 9时11分08秒ERROR捕捉到异常,同时允许TestExecutionListener的[org.springframework.test.context.support.DependencyInjectionTestExecutionListener@112da40]以制备测试例*> [net.tjjang.learn.spring_jpa.test.SrSvcInfoMtrTest @ b6d6ab] java.lang.IllegalStateException:无法在org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)加载ApplicationContext,位于org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java: 109)org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)at org.springframework.test.context .junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)at org.springframework.test.context.junit4.SpringJUnit4C lassRunner $ 1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)位于org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java :290)在org.junit.runners.ParentRunner $ 3上的org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)上的org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) .run(ParentRunner.java:193)at org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:52)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)at org.junit.runners .ParentRunner.access $ org.junit.runners.ParentRunner $(ParentRunner.java:42)$ 2.evaluate(ParentRunner.java:184)at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java :61)at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbac ks.evaluate(RunAfterTestClassCallbacks.java:71)在org.junit.runners.ParentRunner.run(ParentRunner.java:236)在org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)在组织.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)在org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)在org.eclipse.jdt .internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)处org.eclipse.jdt.internal.junit org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) .runner.RemoteTestRunner.run(RemoteTestRunner.java:390)在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 引起的:org.springframework.beans.factory.BeanCreationException:错误创建名为'srSvcInfoMtrRepository'的bean:FactoryBean在创建对象时抛出异常; 嵌套异常是java.lang.NoSuchMethodError:javax.persistence.EntityManager.getMetamodel()Ljavax / persistence / metamodel / Metamodel; at org.springframework.beans.factory org.springframework.support.FactoryBean.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean .org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java)中的org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:305)上的AbstractBeanFactory.getBean(AbstractBeanFactory.java:1441) .java:193)at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)at org.springframework。 org.springframewor上的context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) k.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)在org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)在org.springframework.test.context.support。在org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)处的org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)处委派SmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)。 。24更多>引发:java.lang.NoSuchMethodError:javax.persistence.EntityManager.getMetamodel()Ljavax / persistence / metamodel / Metamodel; * at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport。 java:56)at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:145)at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.g etTargetRepository(JpaRepositoryFactory.java:83)位于org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport。org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:66) (org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:120)at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:39)在org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)

JpaRepository类()

package net.tjjang.learn.spring_jpa.repositories;
import net.tjjang.learn.spring_jpa.domain.SrSvcInfoMtr;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;

@Transactional(readOnly = true)
public interface SrSvcInfoMtrRepository extends JpaRepository<SrSvcInfoMtr, String> {
    Page<SrSvcInfoMtr> findBySvc_nm(String svc_nm, Pageable pageable);
}

app-context.xml(不是app-context.xml的所有内容)

    <!-- for data access -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 
    p:driverClassName="cubrid.jdbc.driver.CUBRIDDriver" p:url="jdbc:cubrid:localhost:30000:test:test::" 
    p:username="test" p:password="*******" p:initialSize="5" p:maxActive="10"> 
    </bean -->
<bean
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
    id="entityManagerFactory">
    <property name="dataSource" ref="dataSource" />
    <property name="loadTimeWeaver">
        <bean
            class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
    </property>
    <property name="persistenceUnitName" value="JpaPersistenceUnit" />
</bean>

<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<jpa:repositories base-package="net.tjjang.learn.spring_jpa" />
<import resource="infrastructure.xml" />

persistence.xml中

    <persistence-unit name="JpaPersistenceUnit"
    transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>net.tjjang.learn.spring_jpa.domain.Car</class>
    <class>net.tjjang.learn.spring_jpa.domain.SrSvcInfoMtr</class>
    <properties>
        <property name="eclipselink.logging.level" value="INFO" />
    </properties>
</persistence-unit>

图书馆

  • 组织 springframework的弹簧AOP 3.1.0.RELEASE 弹簧AOP-3.1.0.RELEASE.jar

  • aopalliance aopalliance 1.0 aopalliance-1.0.jar

  • 组织 springframework的弹簧ASM 3.1.0.RELEASE 弹簧ASM-3.1.0.RELEASE.jar

  • 组织 springframework的弹簧核心 3.1.0.RELEASE 弹簧芯3.1.0.RELEASE.jar

  • 共享记录共享记录 1.1.1 共享记录-1.1.1.jar

  • 组织 springframework的弹簧ORM 3.1.0.RELEASE 弹簧ORM-3.1.0.RELEASE.jar

  • 组织 springframework的弹簧JDBC 3.1.0.RELEASE 弹簧JDBC-3.1.0.RELEASE.jar

  • 组织 springframework的弹簧TX 3.1.0.RELEASE 弹簧TX-3.1.0.RELEASE.jar

  • 组织 springframework的弹簧方面 3.1.0.RELEASE 弹簧方面,3.1.0.RELEASE.jar

  • 组织 springframework的弹簧语境 3.1.0.RELEASE 弹簧上下文3.1.0.RELEASE.jar

  • 有机 springframework的弹簧表达 3.1.0.RELEASE 弹簧表达-3.1.0.RELEASE.jar

  • 有机 springframework的弹簧上下文支持 3.1.0.RELEASE 弹簧上下文支撑3.1.0.RELEASE.jar

  • 组织 springframework的弹簧豆 3.1.0.RELEASE 弹簧豆,3.1.0.RELEASE.jar

  • 有机 springframework的弹簧测试 3.1.0.RELEASE 弹簧 - 测试 - 3.1.0.RELEASE.jar

  • 组织 springframework的弹簧仪 3.1.0.RELEASE 弹簧仪器3.1.0.RELEASE.jar

  • JUnit的的JUnit 4.8.2 的junit-4.8.2.jar

  • 组织 SLF4J SLF4J的API 1.6.0 SLF4J-API-1.6.0.jar

  • 组织 SLF4J JCL-过SLF4J 1.6.0 JCL-过SLF4J-1.6.0.jar

  • 组织 SLF4J SLF4J-log4j12 1.6.0 SLF4J-log4j12-1.6.0.jar

  • log4j的 log4j的 1.2.16 log4j的,1.2.16.jar

  • CUBRID CUBRID-JDBC 8.4.1.2032 CUBRID-JDBC-8.4.1.2032.jar

  • 组织日食执着的EclipseLink 2.0.0 的EclipseLink-2.0.0.jar

  • 有机 springframework的数据弹簧数据JPA 1.0.3.RELEASE 弹簧 - 数据 - JP-A-1.0.3.RELEASE.jar

  • 有机 springframework的数据弹簧数据公地核 1.1.0.RELEASE 弹簧数据公地芯1.1.0.RELEASE.jar

  • 组织冬眠 EJB3持久性 1.0.2.GA EJB3持久性,1.0.2.GA.jar

  • 组织 AspectJ的 aspectjrt 1.6.8 aspectjrt-1.6.8.jar
  • 组织 AspectJ的 aspectjweaver 1.6.11 aspectjweaver,1.6.11.jar
  • 公地DBCP 公地DBCP 1.2.2-P1 公地DBCP-1.2.2-p1.jar
  • commons-pool的 commons-pool的 1.4 commons-pool的-1.4.jar
  • MySQL的 MySQL的连接器的Java 5.1.10 MySQL的连接器的Java-5.1.10.jar

  • Spring Data JPA需要JPA 2.0。 你已经将它的1.0版本拉到你的类路径中(通过任何方式ejb3-persistence-1.0.2.GA.jar )。 确保您使用支持JPA 2.0的最新版本的EclipseLink。 版本2.3.2是当前的发行版本。

    链接地址: http://www.djcxy.com/p/60293.html

    上一篇: JPA + eclipseLink2.0 failed

    下一篇: Does C# optimize the concatenation of string literals?