You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by David Blevins <da...@gmail.com> on 2011/05/24 01:17:03 UTC

Fwd: java.lang.LinkageError

Begin forwarded message:

> From: David Blevins <da...@gmail.com>
> Date: May 23, 2011 2:49:11 PM PDT
> To: users@openejb.apache.org
> Subject: Re: java.lang.LinkageError
> 
> 
> On May 13, 2011, at 3:17 AM, joe wrote:
> 
>> The attached stacktrace is produced everytime the client invokes the call2Methods method after a server restart. All subsequent invocations seem to be ok.
> 
> Hmm.  I've seen that in Geronimo due to issues in the Karaf classloader, but this is the first I've seen of the same bug in the VM classloader.
> 
> In the situation of Karaf, simply "trying again" worked.  We could probably update the 'LocalBeanProxyGeneratorImpl.createProxy' method to catch the LinkageError and simply try creating the proxy again.
> 
> Will suggest this on the dev list and see if someone has some time to work on it (I'm neck deep in CDI changes currently).

Anyone want to hack on this?

We'd need it in trunk and 3.2.


-David


>> 
>> OpenEJB 3.1.4
>> Windows/Unix
>> JDK 1.6.x
>> 
>> 
>> Exception in thread "Thread-1" javax.ejb.EJBException: Cannot obtain a free instance.; nested exception is:
>> 	java.lang.LinkageError: loader (instance of  java/net/URLClassLoader): attempted  duplicate class definition for name: "de/test/dc5/ejb/StartupServiceEJB$LocalBeanProxy"
>> 	at org.apache.openejb.client.EJBInvocationHandler.convertException(EJBInvocationHandler.java:215)
>> 	at org.apache.openejb.client.EJBObjectHandler._invoke(EJBObjectHandler.java:168)
>> 	at org.apache.openejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:118)
>> 	at org.apache.openejb.client.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:52)
>> 	at $Proxy0.testMethod(Unknown Source)
>> 	at de.test.dc.disp_exec.OpenEjbContainer$1.run(OpenEjbContainer.java:34)
>> 	at java.lang.Thread.run(Unknown Source)
>> Caused by: java.lang.LinkageError: loader (instance of java/net/URLClassLoader): attempted  duplicate class definition for name: "de/test/dc5/ejb/StartupServiceEJB$LocalBeanProxy"
>> 	at sun.misc.Unsafe.defineClass(Native Method)
>> 	at org.apache.openejb.util.proxy.LocalBeanProxyGeneratorImpl.createProxy(LocalBeanProxyGeneratorImpl.java:68)
>> 	at org.apache.openejb.util.proxy.LocalBeanProxyGeneratorImpl.createProxy(LocalBeanProxyGeneratorImpl.java:51)
>> 	at org.apache.openejb.util.proxy.LocalBeanProxyFactory.newProxyInstance(LocalBeanProxyFactory.java:27)
>> 	at org.apache.openejb.core.ivm.EjbHomeProxyHandler.createProxy(EjbHomeProxyHandler.java:139)
>> 	at org.apache.openejb.core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:286)
>> 	at org.apache.openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:169)
>> 	at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:282)
>> 	at $Proxy60.create(Unknown Source)
>> 	at org.apache.openejb.core.ivm.naming.openejb.BusinessLocalBeanReference.getObject(BusinessLocalBeanReference.java:34)
>> 	at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:171)
>> 	at org.apache.openejb.core.ivm.naming.IntraVmJndiReference.getObject(IntraVmJndiReference.java:38)
>> 	at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:171)
>> 	at org.apache.openejb.InjectionProcessor.fillInjectionProperties(InjectionProcessor.java:182)
>> 	at org.apache.openejb.InjectionProcessor.construct(InjectionProcessor.java:110)
>> 	at org.apache.openejb.InjectionProcessor.createInstance(InjectionProcessor.java:83)
>> 	at org.apache.openejb.core.stateless.StatelessInstanceManager.ceateInstance(StatelessInstanceManager.java:204)
>> 	at org.apache.openejb.core.stateless.StatelessInstanceManager.getInstance(StatelessInstanceManager.java:165)
>> 	at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
>> 	at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:136)
>> 	at org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:238)
>> 	at org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:129)
>> 	at org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:196)
>> 	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:149)
>> 	at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:71)
>> 	at org.apache.openejb.server.ejbd.KeepAliveServer$Session.service(KeepAliveServer.java:213)
>> 	at org.apache.openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233)
>> 	at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:66)
>> 	at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91)
>> 	at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120)
>> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
>> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>> 	... 1 more
>> 
>> 
> 


Re: java.lang.LinkageError

Posted by Kevan Miller <ke...@gmail.com>.
On May 24, 2011, at 2:36 AM, Romain Manni-Bucau wrote:

> Hi,
> 
> i think it is a bug of the jdk something like now (since 1.6 u18 or u17) it
> is impossible to load an inner class before the containing class. Maybe
> doing a loadClass(StartupServiceEJB.class.getName()) before can help.

I'm not sure when the problem was introduced, and I've not seen an inner class load problem, but would basically agree that this is fundamentally a JSE issue. 

Refining/adding additional information to David's comments:

We've run into a similar problem in Geronimo where classfile transformation could cause redundant/cyclical define class calls on the same thread for the same class. This would only happen for Annotations and Enums. Basic flow was (1) defineClass() -> (2) OpenJPA transform() -> (3) defineClass(). The defineClass() in (3) would work. But the defineClass in (1) ends up throwing a LinkageError.

The Felix classloader detects a cyclical load and avoids the LinkageError failure. Very recent builds of Equinox 3.7 now detect the same situation. In both environments, the defineClass() in (3) now throws a ClassNotFoundException (IIRC). Which is ok. We really don't need to transform the classes, anyway.

In Geronimo we had a work around for the issue by catching the LinkageError thrown by (1) and simply retrying the defineClass() - which will now work (or returns without throwing an exception).

--kevan

Re: java.lang.LinkageError

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

i think it is a bug of the jdk something like now (since 1.6 u18 or u17) it
is impossible to load an inner class before the containing class. Maybe
doing a loadClass(StartupServiceEJB.class.getName()) before can help.


- Romain

2011/5/24 David Blevins <da...@gmail.com>

> Begin forwarded message:
>
> > From: David Blevins <da...@gmail.com>
> > Date: May 23, 2011 2:49:11 PM PDT
> > To: users@openejb.apache.org
> > Subject: Re: java.lang.LinkageError
> >
> >
> > On May 13, 2011, at 3:17 AM, joe wrote:
> >
> >> The attached stacktrace is produced everytime the client invokes the
> call2Methods method after a server restart. All subsequent invocations seem
> to be ok.
> >
> > Hmm.  I've seen that in Geronimo due to issues in the Karaf classloader,
> but this is the first I've seen of the same bug in the VM classloader.
> >
> > In the situation of Karaf, simply "trying again" worked.  We could
> probably update the 'LocalBeanProxyGeneratorImpl.createProxy' method to
> catch the LinkageError and simply try creating the proxy again.
> >
> > Will suggest this on the dev list and see if someone has some time to
> work on it (I'm neck deep in CDI changes currently).
>
> Anyone want to hack on this?
>
> We'd need it in trunk and 3.2.
>
>
> -David
>
>
> >>
> >> OpenEJB 3.1.4
> >> Windows/Unix
> >> JDK 1.6.x
> >>
> >>
> >> Exception in thread "Thread-1" javax.ejb.EJBException: Cannot obtain a
> free instance.; nested exception is:
> >>      java.lang.LinkageError: loader (instance of
>  java/net/URLClassLoader): attempted  duplicate class definition for name:
> "de/test/dc5/ejb/StartupServiceEJB$LocalBeanProxy"
> >>      at
> org.apache.openejb.client.EJBInvocationHandler.convertException(EJBInvocationHandler.java:215)
> >>      at
> org.apache.openejb.client.EJBObjectHandler._invoke(EJBObjectHandler.java:168)
> >>      at
> org.apache.openejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:118)
> >>      at
> org.apache.openejb.client.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:52)
> >>      at $Proxy0.testMethod(Unknown Source)
> >>      at
> de.test.dc.disp_exec.OpenEjbContainer$1.run(OpenEjbContainer.java:34)
> >>      at java.lang.Thread.run(Unknown Source)
> >> Caused by: java.lang.LinkageError: loader (instance of
> java/net/URLClassLoader): attempted  duplicate class definition for name:
> "de/test/dc5/ejb/StartupServiceEJB$LocalBeanProxy"
> >>      at sun.misc.Unsafe.defineClass(Native Method)
> >>      at
> org.apache.openejb.util.proxy.LocalBeanProxyGeneratorImpl.createProxy(LocalBeanProxyGeneratorImpl.java:68)
> >>      at
> org.apache.openejb.util.proxy.LocalBeanProxyGeneratorImpl.createProxy(LocalBeanProxyGeneratorImpl.java:51)
> >>      at
> org.apache.openejb.util.proxy.LocalBeanProxyFactory.newProxyInstance(LocalBeanProxyFactory.java:27)
> >>      at
> org.apache.openejb.core.ivm.EjbHomeProxyHandler.createProxy(EjbHomeProxyHandler.java:139)
> >>      at
> org.apache.openejb.core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:286)
> >>      at
> org.apache.openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:169)
> >>      at
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:282)
> >>      at $Proxy60.create(Unknown Source)
> >>      at
> org.apache.openejb.core.ivm.naming.openejb.BusinessLocalBeanReference.getObject(BusinessLocalBeanReference.java:34)
> >>      at
> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:171)
> >>      at
> org.apache.openejb.core.ivm.naming.IntraVmJndiReference.getObject(IntraVmJndiReference.java:38)
> >>      at
> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:171)
> >>      at
> org.apache.openejb.InjectionProcessor.fillInjectionProperties(InjectionProcessor.java:182)
> >>      at
> org.apache.openejb.InjectionProcessor.construct(InjectionProcessor.java:110)
> >>      at
> org.apache.openejb.InjectionProcessor.createInstance(InjectionProcessor.java:83)
> >>      at
> org.apache.openejb.core.stateless.StatelessInstanceManager.ceateInstance(StatelessInstanceManager.java:204)
> >>      at
> org.apache.openejb.core.stateless.StatelessInstanceManager.getInstance(StatelessInstanceManager.java:165)
> >>      at
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
> >>      at
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:136)
> >>      at
> org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:238)
> >>      at
> org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:129)
> >>      at
> org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:196)
> >>      at
> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:149)
> >>      at
> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:71)
> >>      at
> org.apache.openejb.server.ejbd.KeepAliveServer$Session.service(KeepAliveServer.java:213)
> >>      at
> org.apache.openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233)
> >>      at
> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:66)
> >>      at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91)
> >>      at
> org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120)
> >>      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)
> >>      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> Source)
> >>      ... 1 more
> >>
> >>
> >
>
>