Does this bugreport cover persistent units defined in different persistence.xml 
files too? If I am not mistaken, OpenJPA looks at first persistent unit of 
randomly chosen persistence.xml file.

----- Original Message ----
From: Kevin Sutter (JIRA) <[EMAIL PROTECTED]>
To: open-jpa-dev@incubator.apache.org
Sent: Tuesday, January 9, 2007 11:41:27 AM
Subject: [jira] Created: (OPENJPA-96) Runtime Enhancement only processes first 
persistence unit defined in persistence.xml

Runtime Enhancement only processes first persistence unit defined in 
persistence.xml
------------------------------------------------------------------------------------

                 Key: OPENJPA-96
                 URL: https://issues.apache.org/jira/browse/OPENJPA-96
             Project: OpenJPA
          Issue Type: Bug
          Components: jpa
            Reporter: Kevin Sutter


(This Issue may be related to OPENJPA-9, but since that one was specific to 
static PCEnhancing, I thought I would open a separate Issue.  Just in case the 
solutions are separate.)

I'm using dynamic runtime enhancement via the -javaagent parameter.  It seems 
that only the first persistence-unit defined in the persistence.xml is being 
processed for the runtime enhancement.  If the persistence.xml has only one 
entry, no problem.  But, if it has more than one entry, then only the first 
persistence-unit definition is being processed for the dynamic enhancement.

When I turn trace on, I get the following message when the runtime enhancement 
works:

8312  my persistence unit  INFO   [main] openjpa.MetaData - Found 1 classes 
with metadata in 0 milliseconds.
8943  my persistence unit  TRACE  [main] openjpa.Enhance - 
"com/ibm/ws/persistence/tests/simple/TestEntity" requires runtime enhancement: 
true
9043  my persistence unit  TRACE  [main] openjpa.MetaData - Loading metadata 
for "class com.ibm.ws.persistence.tests.simple.TestEntity" under mode 
"[META][QUERY]".

When this p-u definition is not first in my persistence.xml, the "8943" message 
is missing and my test fails:

8512  my persistence unit  INFO   [main] openjpa.MetaData - Found 1 classes 
with metadata in 0 milliseconds.
8522  my persistence unit  TRACE  [main] openjpa.MetaData - Using metadata 
factory "[EMAIL PROTECTED]".
8522  my persistence unit  TRACE  [main] openjpa.MetaData - Loading metadata 
for "class com.ibm.ws.persistence.tests.simple.TestEntity" under mode 
"[META][QUERY]".

I eventually get the following message when running the testcase:

<4|false|0.0.0> org.apache.openjpa.persistence.ArgumentException: Attempt to 
cast instance "[EMAIL PROTECTED]" to PersistenceCapable failed.  Ensure that it 
has been enhanced.
FailedObject: [EMAIL PROTECTED]
    at 
org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4234)
    at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2344)
    at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2204)
    at 
org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:991)
    at 
org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:525)
    at 
com.ibm.ws.persistence.tests.simple.TestInsertAndFind.test001(TestInsertAndFind.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:615)
    at 
org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
    at 
org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
    at 
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
    at 
org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
    at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
    at 
org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
    at 
org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
    at 
org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
    at 
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
    at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
    at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
    at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Thanks,
Kevin


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



Reply via email to