You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by David Blevins <da...@gmail.com> on 2011/05/10 21:54:07 UTC

LinkageError woes

Running out of places to perform our LinkageError hack.

We've been doing the "try again" routine on all our code (xbean, openwebbeans, etc) and it seems we've followed that path as far as it will lead us.  Currently stuck at the following with no good ideas on how to work around it.


2011-05-10 12:01:17,089 ERROR [[JBoss Test Harness Test Runner]] Servlet.service() for servlet [JBoss Test Harness Test Runner] in context with path [/org.jboss.jsr299.tck.tests.implementation.simple
.resource.persistenceContext.PersistenceContextInjectionTest] threw exception
org.testng.TestNGException: 
Cannot create/initialize the JDK5 annotation finder org.testng.internal.annotations.JDK15AnnotationFinder
        at org.testng.internal.ClassHelper.createJdkAnnotationFinder(ClassHelper.java:186)
        at org.testng.TestNG.initializeAnnotationFinders(TestNG.java:756)
        at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:892)        at org.testng.TestNG.runSuitesLocally(TestNG.java:876)
        at org.testng.TestNG.run(TestNG.java:784)
        at org.jboss.testharness.impl.runner.TestRunner.run(TestRunner.java:61)
        at org.jboss.testharness.impl.runner.servlet.ServletTestRunner.doGet(ServletTestRunner.java:120)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
        at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:696)
        at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:48)
        at org.apache.geronimo.tomcat.valve.ProtectedTargetValve.invoke(ProtectedTargetValve.java:53)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
        at org.apache.geronimo.pool.ThreadPool$1.run(ThreadPool.java:243)
        at org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run(ThreadPool.java:373)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.testng.internal.ClassHelper.createJdkAnnotationFinder(ClassHelper.java:183)
        ... 29 more
Caused by: java.lang.LinkageError: loader (instance of  org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader): attempted  duplicate class definition for name: "org/testng/annotations/Configuratio
n"
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:580)
        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:550)
        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:481)
        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:469)        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:449)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
        at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:393)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:469)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at org.testng.internal.annotations.JDK15AnnotationFinder.<init>(JDK15AnnotationFinder.java:54)
        ... 34 more





Re: LinkageError woes

Posted by Kevan Miller <ke...@gmail.com>.
On May 10, 2011, at 11:01 PM, David Blevins wrote:

> 
> On May 10, 2011, at 6:57 PM, David Blevins wrote:
> 
>> I have a hunch that eagerly loading annotations *and* enums might do the trick.  Going to see if that is the case as that might give us more information about the issue and potentially a workaround that might be one we can stomach.  Loading all the classes eagerly is not ok, but eagerly loading annotation and enum classes might be livable till we can find the real issue.
> 
> Looks like eagerly loading all the application's annotations and enums twice does the trick.  The first time fails with the LinkageError and the second time works.
> 
> Currently performing some magic in debugger with evaluating expressions to get this accomplished.  Not going to codify it just yet, but if we wanted this as a hack as an implemented workaround we'd need to use ASM to scrape and get a list of all annotation and enum classes, put that data in perhaps a gbean that is setup to load on app startup with a dependency on the app classloader, then have that gbean do the double load.  The xbean-finder code doesn't currently have the ability to list annotations and enums -- we'd have to add it or scrape again.
> 
> Hopefully we can find the real issue and not have to do that.

So, I swapped a bit more state back in (how quickly I forget). ClassFile transformation driven by OpenJPA is causing this error. I re-opened our original Jira. I created an Equinox bug report and they've created a patch, which seems to fix our problem. 

There will be the question of how we pick up the fix within Geronimo. The patch is on Equinox 3.7 -- something we probably want to pick up anyway.

--kevan





Re: LinkageError woes

Posted by David Blevins <da...@gmail.com>.
On May 10, 2011, at 6:57 PM, David Blevins wrote:

> I have a hunch that eagerly loading annotations *and* enums might do the trick.  Going to see if that is the case as that might give us more information about the issue and potentially a workaround that might be one we can stomach.  Loading all the classes eagerly is not ok, but eagerly loading annotation and enum classes might be livable till we can find the real issue.

Looks like eagerly loading all the application's annotations and enums twice does the trick.  The first time fails with the LinkageError and the second time works.

Currently performing some magic in debugger with evaluating expressions to get this accomplished.  Not going to codify it just yet, but if we wanted this as a hack as an implemented workaround we'd need to use ASM to scrape and get a list of all annotation and enum classes, put that data in perhaps a gbean that is setup to load on app startup with a dependency on the app classloader, then have that gbean do the double load.  The xbean-finder code doesn't currently have the ability to list annotations and enums -- we'd have to add it or scrape again.

Hopefully we can find the real issue and not have to do that.

-David






Re: LinkageError woes

Posted by David Blevins <da...@gmail.com>.
On May 10, 2011, at 5:56 PM, Kevan Miller wrote:

> 
> On May 10, 2011, at 8:19 PM, David Blevins wrote:
> 
>> 
>> On May 10, 2011, at 3:48 PM, Kevan Miller wrote:
>> 
>>> 
>>> On May 10, 2011, at 5:08 PM, Kevan Miller wrote:
>>> 
>>>> 
>>>> On May 10, 2011, at 3:54 PM, David Blevins wrote:
>>>> 
>>>>> Running out of places to perform our LinkageError hack.
>>>>> 
>>>>> We've been doing the "try again" routine on all our code (xbean, openwebbeans, etc) and it seems we've followed that path as far as it will lead us.  Currently stuck at the following with no good ideas on how to work around it.
>>>> 
>>>> Yuck. Thanks for getting us this far!
>>>> 
>>>> For some reason, I had the notion that this was all going to be resolved by moving up to the latest OpenJPA release. Obviously, I was mis-guided (at best) and definitely hadn't gotten to the test validation stage. 
>>>> 
>>>> I guess OpenJPA would be where I might hope we could resolve... I can try banging my head against the wall for a bit...
>>> 
>>> Well, one reason why OpenJPA wouldn't help resolve is if OpenJPA weren't involved... Hmph.
>>> 
>>> If my memory is correct, this will work on Felix...
>> 
>> Indeed it seems like an Equinox issue.
>> 
>> Tried a hack involving wrapping the classloader with one that double-tries loadClass if a LinkageError is thrown.  Didn't work.  Might have needed to have done the hack a little deeper -- I just did the wrapping in TomcatWebAppContext.
>> 
>> At the moment trying to find at least some dirty hack that will let me get far enough to see if the test will pass sans this issue.  Current hack idea: eagerly load all annotation classes.
> 
> Started looking at Equinox code a bit. Also sent of a question. See who gets there first...

Eagerly loading annotation classes alone didn't do the trick.  Loading *all* the classes does work and results in all 5 persistence tests to pass.

I have a hunch that eagerly loading annotations *and* enums might do the trick.  Going to see if that is the case as that might give us more information about the issue and potentially a workaround that might be one we can stomach.  Loading all the classes eagerly is not ok, but eagerly loading annotation and enum classes might be livable till we can find the real issue.

-David




Re: LinkageError woes

Posted by Kevan Miller <ke...@gmail.com>.
On May 10, 2011, at 8:19 PM, David Blevins wrote:

> 
> On May 10, 2011, at 3:48 PM, Kevan Miller wrote:
> 
>> 
>> On May 10, 2011, at 5:08 PM, Kevan Miller wrote:
>> 
>>> 
>>> On May 10, 2011, at 3:54 PM, David Blevins wrote:
>>> 
>>>> Running out of places to perform our LinkageError hack.
>>>> 
>>>> We've been doing the "try again" routine on all our code (xbean, openwebbeans, etc) and it seems we've followed that path as far as it will lead us.  Currently stuck at the following with no good ideas on how to work around it.
>>> 
>>> Yuck. Thanks for getting us this far!
>>> 
>>> For some reason, I had the notion that this was all going to be resolved by moving up to the latest OpenJPA release. Obviously, I was mis-guided (at best) and definitely hadn't gotten to the test validation stage. 
>>> 
>>> I guess OpenJPA would be where I might hope we could resolve... I can try banging my head against the wall for a bit...
>> 
>> Well, one reason why OpenJPA wouldn't help resolve is if OpenJPA weren't involved... Hmph.
>> 
>> If my memory is correct, this will work on Felix...
> 
> Indeed it seems like an Equinox issue.
> 
> Tried a hack involving wrapping the classloader with one that double-tries loadClass if a LinkageError is thrown.  Didn't work.  Might have needed to have done the hack a little deeper -- I just did the wrapping in TomcatWebAppContext.
> 
> At the moment trying to find at least some dirty hack that will let me get far enough to see if the test will pass sans this issue.  Current hack idea: eagerly load all annotation classes.

Started looking at Equinox code a bit. Also sent of a question. See who gets there first...

--kevan

Re: LinkageError woes

Posted by David Blevins <da...@gmail.com>.
On May 10, 2011, at 3:48 PM, Kevan Miller wrote:

> 
> On May 10, 2011, at 5:08 PM, Kevan Miller wrote:
> 
>> 
>> On May 10, 2011, at 3:54 PM, David Blevins wrote:
>> 
>>> Running out of places to perform our LinkageError hack.
>>> 
>>> We've been doing the "try again" routine on all our code (xbean, openwebbeans, etc) and it seems we've followed that path as far as it will lead us.  Currently stuck at the following with no good ideas on how to work around it.
>> 
>> Yuck. Thanks for getting us this far!
>> 
>> For some reason, I had the notion that this was all going to be resolved by moving up to the latest OpenJPA release. Obviously, I was mis-guided (at best) and definitely hadn't gotten to the test validation stage. 
>> 
>> I guess OpenJPA would be where I might hope we could resolve... I can try banging my head against the wall for a bit...
> 
> Well, one reason why OpenJPA wouldn't help resolve is if OpenJPA weren't involved... Hmph.
> 
> If my memory is correct, this will work on Felix...

Indeed it seems like an Equinox issue.

Tried a hack involving wrapping the classloader with one that double-tries loadClass if a LinkageError is thrown.  Didn't work.  Might have needed to have done the hack a little deeper -- I just did the wrapping in TomcatWebAppContext.

At the moment trying to find at least some dirty hack that will let me get far enough to see if the test will pass sans this issue.  Current hack idea: eagerly load all annotation classes.


-David


Re: LinkageError woes

Posted by Kevan Miller <ke...@gmail.com>.
On May 10, 2011, at 5:08 PM, Kevan Miller wrote:

> 
> On May 10, 2011, at 3:54 PM, David Blevins wrote:
> 
>> Running out of places to perform our LinkageError hack.
>> 
>> We've been doing the "try again" routine on all our code (xbean, openwebbeans, etc) and it seems we've followed that path as far as it will lead us.  Currently stuck at the following with no good ideas on how to work around it.
> 
> Yuck. Thanks for getting us this far!
> 
> For some reason, I had the notion that this was all going to be resolved by moving up to the latest OpenJPA release. Obviously, I was mis-guided (at best) and definitely hadn't gotten to the test validation stage. 
> 
> I guess OpenJPA would be where I might hope we could resolve... I can try banging my head against the wall for a bit...

Well, one reason why OpenJPA wouldn't help resolve is if OpenJPA weren't involved... Hmph.

If my memory is correct, this will work on Felix...

--kevan

Re: LinkageError woes

Posted by Kevan Miller <ke...@gmail.com>.
On May 10, 2011, at 3:54 PM, David Blevins wrote:

> Running out of places to perform our LinkageError hack.
> 
> We've been doing the "try again" routine on all our code (xbean, openwebbeans, etc) and it seems we've followed that path as far as it will lead us.  Currently stuck at the following with no good ideas on how to work around it.

Yuck. Thanks for getting us this far!

For some reason, I had the notion that this was all going to be resolved by moving up to the latest OpenJPA release. Obviously, I was mis-guided (at best) and definitely hadn't gotten to the test validation stage. 

I guess OpenJPA would be where I might hope we could resolve... I can try banging my head against the wall for a bit...

--kevan