Исключение в родной части openejb

Я начинаю новую тему для своей проблемы, так как я упомянул некоторые неправильные вещи в старой.

Я использую openejb для написания интеграционных тестов для своих bean-компонентов с использованием jpa. В настоящее время у меня есть исключение в некоторых собственных вызовах, сделанных jpa:

INFO - Creating subclass and redefining methods for "[class ContextKey, class ContextEntity]". This means that your application will be less efficient than it would if you ran the OpenJPA enhancer.
SEVERE - EjbTransactionUtil.handleSystemException: null
<openjpa-2.3.0-nonfinal-1540826-r422266:1542644 fatal general error> org.apache.openjpa.persistence.PersistenceException: null
    at org.apache.openjpa.enhance.ClassRedefiner.redefineClasses(ClassRedefiner.java:96)
    at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:176)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:312)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:236)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:212)
    at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:155)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:226)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:59)
    at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createEntityManager(ReloadableEntityManagerFactory.java:159)
    at org.apache.openejb.persistence.JtaEntityManagerRegistry.getEntityManager(JtaEntityManagerRegistry.java:115)
    at org.apache.openejb.persistence.JtaEntityManager.getEntityManager(JtaEntityManager.java:91)
    at org.apache.openejb.persistence.JtaEntityManager.persist(JtaEntityManager.java:137)
    at com.six.ao.atm.database.context.AtmContextBean.persistWithCommit(AtmContextBean.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:182)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:164)
    at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:180)
    at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:99)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:182)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:164)
    at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:80)
    at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:212)
    at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:181)
    at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:268)
    at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:263)
    at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:86)
    at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:303)
    at com.sun.proxy.$Proxy68.persistWithCommit(Unknown Source)
    at com.six.ao.atm.database.context.AtmContextBeanIT.persistWithCommit_readAfter_sameObject(AtmContextBeanIT.java:43)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.openjpa.enhance.ClassRedefiner.redefineClasses(ClassRedefiner.java:85)
    ... 60 more
Caused by: java.lang.VerifyError
    at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
    at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:144)
    ... 65 more

Сначала я думал, что мои классы не улучшены, но, как упоминается в первой строке, классы являются подклассами, так как я не использую агент java для улучшения.

Вот мой файл persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence ...>
  <persistence-unit name="atm">
    <jta-data-source>java:/atmAoDS</jta-data-source>
    <properties>
        <property name="showSql" value="false"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /> 
    </properties>
  </persistence-unit>
</persistence>

Любая идея?


person boskop    schedule 07.04.2014    source источник
comment
Какую версию Java вы используете?   -  person Rick    schedule 07.04.2014
comment
Java 1.7 (версия 51)   -  person boskop    schedule 08.04.2014
comment
и содержимое вашего файла persistence.xml?   -  person Rick    schedule 08.04.2014
comment
Я добавил свой файл persistence.xml к вопросу. Я пытался использовать определенный файл persistence.xml для своих тестов, но затем у меня есть исключение, что мой модуль определяется дважды.   -  person boskop    schedule 08.04.2014
comment
Как я упоминал в другом сообщении, не используйте RuntimeUnenhancedClasses.   -  person Rick    schedule 08.04.2014


Ответы (1)


Столкнулся с той же ошибкой при тестировании моего кода с использованием OpenEJB. На самом деле важен последний фрагмент вашей трассировки исключений.

Caused by: java.lang.VerifyError
at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:144)

Решение можно найти в последнем ответе Доминика java.lang.VerifyError: Ожидается кадр карты стека. Просто установите -XX:-UseSplitVerifier.

PS: пытался использовать Enhancement, как указано здесь Разрешено ли методу в объекте JPA вызывать исключение? Рик и здесь http://openjpa.208410.n2.nabble.com/Fwd-org-apache-openjpa-persistence-PersistenceException-null-td7584865.html но столкнулся с парой препятствий. Первое было преодолено с помощью рецепта выше, но второе, возможно, является ошибкой https://issues.apache.org/jira/browse/OPENJPA-1879 при использовании расширения с Eclipse.

След читается так.

<openjpa-2.3.0-nonfinal-1540826-r422266:1542644 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: Primary key field YOUR_CLASS.id of YOUR_CLASS@755629fd has non-default value. The instance life cycle is in PNewState state and hence an existing non-default value for the identity field is not permitted. You either need to remove the @GeneratedValue annotation or modify the code to remove the initializer processing.
person javaeeeee    schedule 22.10.2014