2016-05-17 70 views
0

我有三個捆綁。在第一個包中,我有persistence.xml。我有兩個類:A和B.擴展B.類A是@Entity,類B是@ MappedSuperclass。兩個類都在persistence.xml中列出。 2'dn和3'rd捆綁包的包被導出。Eclipselink:OSGi包,繼承和編織

如果A類和B類在同一個包中 - 一切正常。然而,當第二束和B級A級是第三個包,我得到:

WARNING: EMFProxy invocation on method createEntityManager failed: Exception: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.6.3.v20160428-59c81c5): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException 
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: [email protected] 
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.6.3.v20160428-59c81c5): org.eclipse.persistence.exceptions.EntityManagerSetupException 
Exception Description: Predeployment of PersistenceUnit [myPersistenceUnit] failed. 
Internal Exception: java.lang.NullPointerException 
java.lang.NullPointerException: null 
    at org.eclipse.persistence.internal.jpa.weaving.TransformerFactory.createClassDetails(TransformerFactory.java:270) 
    at org.eclipse.persistence.internal.jpa.weaving.TransformerFactory.addClassDetailsForMappedSuperClasses(TransformerFactory.java:124) 
    at org.eclipse.persistence.internal.jpa.weaving.TransformerFactory.buildClassDetailsAndModifyProject(TransformerFactory.java:180) 
    at org.eclipse.persistence.internal.jpa.weaving.TransformerFactory.createTransformerAndModifyProject(TransformerFactory.java:84) 
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1972) 
    at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:100) 
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:104) 
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:188) 
    at org.eclipse.gemini.jpa.ProviderWrapper.createEntityManagerFactory(ProviderWrapper.java:128) 
    at org.eclipse.gemini.jpa.proxy.EMFServiceProxyHandler.createEMF(EMFServiceProxyHandler.java:151) 
    at org.eclipse.gemini.jpa.proxy.EMFServiceProxyHandler.syncGetEMFAndSetIfAbsent(EMFServiceProxyHandler.java:127) 
    at org.eclipse.gemini.jpa.proxy.EMFServiceProxyHandler.invoke(EMFServiceProxyHandler.java:73) 
    at com.sun.proxy.$Proxy8.createEntityManager(Unknown Source) 

當我在persistence.xml中設置

<property name="eclipselink.weaving" value="false"/> 

我沒有得到任何異常,但B類的所有字段都被忽略。如何解決這個問題呢?

+0

將EclipseLink日誌記錄設置爲最好或全部並檢出日誌,因爲EclipseLink在部署期間正在加載每個類,以查看是否所有的類都被拾取。它應該顯示任何可能阻止「B」加載的警告或錯誤。 – Chris

+0

@Chris謝謝你的時間。它沒有幫助,但它提供了一個提示 - 我注意到來自其中一個包的任何類都被忽略,最終找出原因。看到我的答案。 –

+0

@Chris順便說一下,是否有什麼辦法讓一些Maven bundle讀取persistence.xml類並添加缺少的包到manifest?還是其他的好方法? –

回答

0

問題出在第一包。它沒有從類B的包中導入包,因爲它的代碼不知道類B的任何內容。所以我必須在第一個包的osgi指令導入包 - 類B包中添加清單文件。 EclipseLink中的問題在於,即使記錄級別爲All,它也沒有拋出任何有關未找到的類的異常或類似的情況。