2013-02-21 2 views
0

환경 : Tomcat- 웹 서버, eclipselink-2.4.1 (Juno) JPA, Odata4j Eclipse 링크로 JPA (테이블에서 동적 엔티티 생성)를하고 있습니다. 내 persistence.xml을 보이는 공급자 클래스에서Eclipse 링크로 동적 클래스 로더를 지정하는 방법

<persistence-unit name="abcLink" 
     transaction-type="RESOURCE_LOCAL"> 
     <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
     <mapping-file>META-INF/eclipselink-orm.xml</mapping-file>   
     <properties> 
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /> 
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/netspectiveauthentication?zeroDateTimeBehavior=convertToNull"/> 
      <property name="javax.persistence.jdbc.user" value="root" /> 
      <property name="javax.persistence.jdbc.password" value="" /> 
      <property name="eclipselink.ddl-generation" value="create-tables" /> 
      <property name="eclipselink.logging.level" value="INFO" /> 
      <property name="eclipselink.logging.exceptions" value="true" />  
     </properties> 
    </persistence-unit> 

및 같은

String persistenceUnitName = "abcLink";  
      EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName,properties); 
      emf.createEntityManager();     
      return new JPAProducer(emf, "abcd", 20); 

속성 'I을 실행하는 동안 기능 을 만들 ODataProducer 를 재정 의하여 얻을 것이다, 그래서 내가 ODATA4j 구현을 위해 이것을 사용하고 있습니다 다음 오류가 발생합니다

javax.persistence.PersistenceException: Exception [EclipseLink-28017] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.EntityManagerSetupException 
Exception Description: Unable to predeploy PersistenceUnit [AuthenticationServiceEclipseMysqlLink] in invalid state [DeployFailed]. 
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.EntityManagerSetupException 
Exception Description: Deployment of PersistenceUnit [AuthenticationServiceEclipseMysqlLink] failed. Close all factories for this PersistenceUnit. 
Internal Exception: Exception [EclipseLink-7328] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.ValidationException 
Exception Description: When using VIRTUAL access a DynamicClassLoader must be provided when creating the entity manager factory using the eclipselink property [eclipselink.classloader]. That is, createEntityManagerFactory(String persistenceUnitName, Map properties) and add a new DynamicClassLoader() to the Map properties. 
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1226) 
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:134) 
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source) 

오류가 분명하다고 생각합니다. 하지만 알고 싶은, 어떻게 속성을 통해 동적 클래스 로더를 제공 할 수 있습니다. 또는이 오류를 제거 할 수있는 다른 방법이 있습니다.

답변

1

main 메서드의 시작 부분에 this example을보십시오.

+0

샘플을 보내 주셔서 감사합니다. ur 샘플 파일의 도움으로 클래스 로더를 설정했습니다. 내가 https://bugs.eclipse.org/bugs/show_bug.cgi?id=397283에서 지정하는 오류가 있습니다. 따라서 동적 인 진행이 없습니다. 동적으로 일시적으로 중지되었습니다. 이제 정적 클래스로 검사합니다. 어떤면에서이 유형의 예제를 찾을 수 있는지 제안 해주십시오. – Abdul

+0

Google :) 진심으로, 중요한 키워드를 포함하는 오류 메시지의 하위 문자열을 식별하고 Google에 하위 문자열을 지정해야합니다. 예 : https://www.google.com/search?q=add+a+new+DynamicClassLoader()+to+the+Map+properties&oq=add+a+new+DynamicClassLoader()+to+the+Map + 속성 – gcvt

관련 문제