访问 EntityManager 时出错 - openjpa - WAS 自由配置文件
Error while accessing EntityManager - openjpa - WAS liberty profile
我目前正在 WebSphere Application Server Liberty Profile 8.5.5.7. 上开发一个 openjpa 项目,数据库为 MySQL
在运行期间,当我尝试访问 实体管理器 时,我收到如下错误:
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]
目前我正在使用以下 dependencies:org.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]
您指定了 jpa-2.1,但 OpenJPA 不支持 JPA 2.1。 WebSphere 附带的 JPA 2.1 提供程序是 EclipseLink。您需要从 persistence.xml 中删除对 OpenJPA 的引用并使用默认的 EclipseLink(尽管有一些 known behavior changes),或者按照 Gas 的建议,您需要将 webProfile-7.0 和 jpa-2.1 替换为jpa-2.0 如果您想继续使用 OpenJPA。
我目前正在 WebSphere Application Server Liberty Profile 8.5.5.7. 上开发一个 openjpa 项目,数据库为 MySQL
在运行期间,当我尝试访问 实体管理器 时,我收到如下错误:
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]
目前我正在使用以下 dependencies:org.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]
您指定了 jpa-2.1,但 OpenJPA 不支持 JPA 2.1。 WebSphere 附带的 JPA 2.1 提供程序是 EclipseLink。您需要从 persistence.xml 中删除对 OpenJPA 的引用并使用默认的 EclipseLink(尽管有一些 known behavior changes),或者按照 Gas 的建议,您需要将 webProfile-7.0 和 jpa-2.1 替换为jpa-2.0 如果您想继续使用 OpenJPA。