2013-02-21 47 views
0

環境: Tomcat Web服務器,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); 

我用這對ODATA4j實施,使屬性將通過覆蓋 同時運行I」 ODataProducer創建功能 得到m得到以下錯誤

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

看看this example,在main方法的開頭。

+0

感謝您的示例。我在你的示例文件的幫助下設置了類加載器。還有我得到一個錯誤,在https://bugs.eclipse.org/bugs/show_bug.cgi?id=397283中指定。所以沒有動態的進展。暫時停止動態,現在檢查靜態類。任何方式,你可以請建議我在哪裏可以找到這些類型的例子。 – Abdul 2013-02-22 06:40:54

+0

Google :)認真地說,您應該確定包含重要關鍵字的錯誤消息的子字符串,以及谷歌子字符串。例如:https://www.google.com/search?q=add+a+new+DynamicClassLoader()+to+the+Map+properties&oq=add+a+new+DynamicClassLoader()+to+the+Map +性能 – gcvt 2013-02-22 14:06:23

相關問題