2015-10-19 113 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

相关问题