You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Kevin Sutter (JIRA)" <ji...@apache.org> on 2007/01/09 18:14:27 UTC

[jira] Created: (OPENJPA-97) Runtime Enhancement without entries in persistence.xml fails while attempting to process non-Entity classes

Runtime Enhancement without <class> entries in persistence.xml fails while attempting to process non-Entity classes
-------------------------------------------------------------------------------------------------------------------

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


When using dynamic Runtime Enhancement (-javaagent) and not having the explicit set of classes defined in persistence.xml, the processing gets sick once in a while.  It starts off fine with the appropriate warning...

160  my persistence unit  INFO   [main] openjpa.Enhance - You have enabled runtime enhancement, but have not specified the set of persistent classes.  OpenJPA must look for metadata for every loaded class, which might increase class load times significantly.

It then starts parsing (and processing) every package and class that gets loaded...

210  my persistence unit  INFO   [main] openjpa.MetaData - Parsing class "org.eclipse.jdt.internal.junit.runner.RemoteTestRunner".
210  my persistence unit  INFO   [main] openjpa.MetaData - Parsing package "org.eclipse.jdt.internal.junit.runner.RemoteTestRunner".
230  my persistence unit  INFO   [main] openjpa.MetaData - Parsing class "org.eclipse.jdt.internal.junit.runner.MessageSender".
230  my persistence unit  INFO   [main] openjpa.MetaData - Parsing class "org.eclipse.jdt.internal.junit.runner.IVisitsTestTrees".
230  my persistence unit  INFO   [main] openjpa.MetaData - Parsing class "org.eclipse.jdt.internal.junit.runner.IListensToTestExecutions".
:
:

But, it also hits "warnings" similar to the following:

530  my persistence unit  WARN   [main] openjpa.Enhance - An exception was thrown while attempting to perform class file transformation on "$Proxy3":
<0|false|0.0.0> org.apache.openjpa.util.GeneralException: $Proxy3
	at org.apache.openjpa.enhance.PCClassFileTransformer.needsEnhance(PCClassFileTransformer.java:179)
	at org.apache.openjpa.enhance.PCClassFileTransformer.transform(PCClassFileTransformer.java:117)
	at sun.instrument.TransformerManager.transform(TransformerManager.java:141)
	at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:174)
	at java.lang.reflect.Proxy.defineClass0(Native Method)
	at java.lang.reflect.Proxy.getProxyClass(Proxy.java:515)
	at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:592)
	at com.ibm.oti.reflect.AnnotationHelper.getAnnotation(AnnotationHelper.java:34)
	at com.ibm.oti.reflect.AnnotationHelper.getDeclaredAnnotations(AnnotationHelper.java:50)
	at com.ibm.oti.reflect.Method.getDeclaredAnnotations(Method.java:31)
	at java.lang.reflect.Method.getDeclaredAnnotations(Method.java:704)
	at java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.java:191)
	at com.ibm.oti.reflect.Method.getAnnotation(Method.java:20)
	at java.lang.reflect.Method.getAnnotation(Method.java:693)
	at org.junit.internal.runners.TestIntrospector.getTestMethods(TestIntrospector.java:28)
	at org.junit.internal.runners.TestClassMethodsRunner.<init>(TestClassMethodsRunner.java:27)
	at org.junit.internal.runners.TestClassRunner.<init>(TestClassRunner.java:20)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:521)
	at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:26)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:24)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:34)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:24)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
	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)
Caused by: java.lang.ClassNotFoundException: $Proxy3
	at java.lang.Class.forName(Class.java:160)
	at org.apache.openjpa.enhance.PCClassFileTransformer.needsEnhance(PCClassFileTransformer.java:171)
	... 29 more

There are similar ClassNotFoundExceptions for the following classes that were loaded (in my test scenario):

sun.reflect.GeneratedMethodAccessor1
sun.reflect.GeneratedConstructorAccessor1
sun.reflect.GeneratedConstructorAccessor2
sun.reflect.GeneratedConstructorAccessor3
sun.reflect.GeneratedConstructorAccessor4
$Proxy7
$Proxy8
$Proxy9

Since these are obviously not Entities, maybe we should just eat these exceptions.  That is, assume that any errors that happen during the parsing phase just indicate that they are not Entities and continue on.  Currently, the "warning" message and call stack look a bit more drastic than what they really are.

BTW, the rest of the runtime enhancement worked just fine.  It parsed several hundred class files as they were being loaded.  It found the one class file that I was interested in and successfully enhanced it.  So, the processing worked okay.  It's just kind of messy.

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