2012-05-14 6 views
0

私のテストプロジェクトでは、Springコンテナは次のエラーのためにJpaRepositoryを拡張するBeanを作成できません。SPRING DATA-JPA + eclipseLink2.0が失敗しました

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'srSvcInfoMtrRepository': FactoryBean threw exception on object creation; nested exception is 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 09:11:08 ERROR Caught exception while allowing TestExecutionListener [org.springframewor[email protected]112da40] to prepare test instance *> [[email protected]] java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) at 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.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.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$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'srSvcInfoMtrRepository': FactoryBean threw exception on object creation; nested exception is java.lang.NoSuchMethodError: javax.persistence.EntityManager.getMetamodel()Ljavax/persistence/metamodel/Metamodel; at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102) at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1441) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:305) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.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.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1) at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228) at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124) at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148) ... 24 more > Caused by: 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.getTargetRepository(JpaRepositoryFactory.java:83) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:66) at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:146) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:120) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:39) at 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> 

ライブラリ

  • \ orgの\ springframework \春-AOP \ 3.1.0.RELEASE \ spring- aop-3.1.0.RELEASE.jar

  • \ aopalliance \ aopalliance \ 1.0 \ aopalliance-1.0.jar

  • \ orgの\ springframework \春-ASMの\ 3.1.0.RELEASEの\スプリング-ASM-3.1.0.RELEASE.jar

  • \ orgの\ springframework \春・コア\の3.1.0.RELEASEの\スプリングコア - 3.1.0.RELEASE.jar

  • コモンズロギング\コモンズ・ログ\ 1.1.1 \コモンズ、ログ\ -1.1.1.jar

  • \ org \ springframework \ spring-orm \ 3.1.0.RELEASE \ spリング-ORM-3.1.0.RELEASE.jar

  • \ orgの\ springframework \春-JDBCの\ 3.1.0.RELEASEの\春-JDBC-3.1.0.RELEASE.jar

  • \ ORG \ springframework \ spring-tx \ 3.1.0.RELEASE \ spring-tx-3.1.0.RELEASE.jar

  • \ org \ springframework \ spring-aspects \ 3.1.0.RELEASE \ spring-aspects-3.1.0 .RELEASE.jar

  • \ org \ springframework \ spring-context \ 3.1.0.RELEASE \ spring-context-3.1.0.RELEASE。3.1 \

  • \ orgの\ springframework \春表現の\ 3.1.0.RELEASEの\春-表現-3.1.0.RELEASE.jar

  • \ orgの\ springframework \春・コンテキストのサポートをjarファイル。 0.RELEASE \春・コンテキストのサポート - 3.1.0.RELEASE.jar

  • \ orgの\ springframework春豆\ 3.1.0.RELEASEの\の\春豆-3.1.0.RELEASE.jar

  • \ org \ springframework \ spring-test \ 3.1.0.RELEASE \ spring-test-3.1.0.RELEASE.jar

  • \ orgの\ springframework春-楽器\ \ 3.1.0.RELEASEの\スプリング・楽器3.1.0.RELEASE.jar

  • のJUnit \ \のJUnitを\ 4.8.2 \ JUnitの-4.8.2.jar

  • \ orgの\ SLF4J \ SLF4J-API \ 1.6.0 \ SLF4J-API-1.6.0.jar

  • \ orgの\ SLF4J 1.6.0 \ JCLオーバー\ JCLオーバーSLF4J \ -slf4j-1.6.0.jar

  • \ orgの\ 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 \

  • \ ORG \日食\永続\ EclipseLinkは\ 2.0.0 \ EclipseLinkの-2.0.0.jar

  • \ orgの\ springframework \データ\春データ-JPA \ 1.0.3.RELEASE \春-データ-JPA-1.0。 3.RELEASE.jar

  • \ org \ springframework \ data \ spring-data-commons-core \ 1.1.0.RELEASE \ spring-data-commons-core-1.1.0.RELEASE.jar

  • \ orgの\ \ EJB3永続性の\ 1.0.2.GAの\ EJB3永続性-1.0.2.GA.jar

  • \ orgの\ AspectJの\ aspectjrt \ 1.6.8 \ aspectjrt-1.6を休止。 8.jar
  • \ org \ aspectj \ aspectjweaver \ 1.6.11 \ aspectjweaver-1.6.11.jar
  • \ commons-dbcp \ commons-dbcp \ 1.2.2-p1 \ commons-dbcp-1.2.2- p1.jar
  • \ commons-pool \ commons-pool \ 1.4 \ commons-pool-1.4.jar
  • \ mysql \ mysql-connector-java \ 5.1.10 \ mysql-connector-java-5.1.10。ジャー

答えて

5

スプリングデータJPAにはJPA 2.0が必要です。 1.0のバージョンをクラスパスに入れました(どんな方法であれejb3-persistence-1.0.2.GA.jar)。 JPA 2.0をサポートする最新版のEclipseLinkを使用していることを確認してください。バージョン2.3.2が現在のリリースバージョンです。

関連する問題