2015-10-19 119 views
2

我目前正在開發一個openjpa項目,其中WebSphere Application Server Liberty配置文件8.5.5.7。與數據庫是MySQL的訪問EntityManager時出錯 - openjpa - WAS liberty配置文件

在運行時,當我試圖訪問實體管理器,我得到的錯誤,如:

Caused by: javax.ejb.EJBException: See nested exception; nested exception is: java.lang.Exception: See nested Throwable at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:461) ... 27 more
Caused by: java.lang.Exception: See nested Throwable at com.ibm.ejs.container.util.ExceptionUtil.Exception(ExceptionUtil.java:317) ... 27 more

Caused by: java.lang.AbstractMethodError: org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(Ljavax/persistence/SynchronizationType;Ljava/util/Map;)Ljavax/persistence/EntityManager;
at com.ibm.ws.jpa.container.v21.internal.JPA21Runtime.createEntityManagerInstance(JPA21Runtime.java:104) at [internal classes]

目前

我用下面的依賴關係:組織.apache.openjpa:OpenJPA的-ALL-2.4.0

在部署過程中,我看到下面的堆棧跟蹤

[err] 458 appname INFO [Default Executor-thread-16] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary" (MySQL 5.6.25-0ubuntu0.15.04.1 ,MySQL-AB JDBC Driver mysql-connector-java-5.0.8 (Revision: ${svn.Revision})).

[err] 502 appname INFO [Default Executor-thread-16] openjpa.jdbc.JDBC - Connected to MySQL version 5.5 using JDBC driver MySQL-AB JDBC Driver version mysql-connector-java-5.0.8 (Revision: ${svn.Revision}).

但是這並沒有中止我的部署過程,我仍然可以使用我的服務。

增加了以下功能server.xml中

<featureManager> 
    <feature>webProfile-7.0</feature> 
    <feature>localConnector-1.0</feature> 
    <feature>jndi-1.0</feature> 
    <feature>jdbc-4.1</feature> 
    <feature>jaxrs-2.0</feature> 
    <feature>jpa-2.1</feature> 
</featureManager> 

假定它是一個兼容性問題,我用舊版本的OpenJPA的2.2.1爲止。
從server.xml中禁用jpa-2.1功能
但是沒有運氣。

對上述問題的任何信息/參考/解決方案非常感謝。由於


更新: 感謝您的更新。 更新了server.xml中爲

<featureManager> 
    <feature>localConnector-1.0</feature> 
    <feature>jndi-1.0</feature> 
    <feature>jdbc-4.1</feature> 
    <feature>jpa-2.0</feature> 
    <feature>jaxrs-2.0</feature> 
    <feature>jaxrsClient-2.0</feature> 
    <feature>ejbLite-3.2</feature> 
</featureManager> 

這仍然不能挑的EntityManager。

[ERROR ] Error occurred during error handling, give up! nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: java.lang.NullPointerException while invoking public void foo() with params [].
[ERROR ] SRVE0777E: Exception thrown by application class 'org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage:116' java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: java.lang.NullPointerException while invoking public void foo() with params [].
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:116) at [internal classes]
Caused by: org.apache.cxf.interceptor.Fault: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is:
java.lang.NullPointerException while invoking public void foo() with params [].
at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:167)
... 1 more
Caused by: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: java.lang.NullPointerException at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapCSIException(BusinessExceptionMappingStrategy.java:124) at [internal classes]

+2

嘗試刪除'webProfile-7.0',如果您想使用該版本,請添加'jpa-2.0'並從應用程序中刪除jpa jar。 – Gas

回答

4

您已指定jpa-2.1,但OpenJPA不支持JPA 2.1。 WebSphere中包含的JPA 2.1提供程序是EclipseLink。您可能需要從persistence.xml中刪除對OpenJPA的引用,並使用默認的EclipseLink(儘管有一些known behavior changes),或者如Gas建議的那樣,如果需要,您需要用jpa-2.0替換webProfile-7.0和jpa-2.1繼續使用OpenJPA。

+0

嗨,這在一定程度上有所幫助,但仍然無法挑選實體管理器。請查看我看到空指針異常的更新,因爲EntityManager未注入到我的Dao類中。 – SashankNori

+0

@SashankNori完整的堆棧跟蹤在messages.log中。你可以發佈,而不是從console.log截斷的嗎? –

+0

我觀察到功能jpa-2.0沒有安裝或作爲WAS liberty 8.5.5.7的一個功能。 因此,使用命令 **/wlp/bin/installUtility'install jpa-2.0 ** 手動安裝這解決了問題。 在此感謝您的幫助。 – SashankNori

相關問題