Error java.lang.LinkageError: loader constraint violation: loader

636 views
Skip to first unread message

Laurent Schweizer

unread,
Jun 17, 2014, 5:16:02 AM6/17/14
to mobicent...@googlegroups.com

Dear all,

 

I have sometimes this error, any idea ?

 

BR

Laurent

 

java.lang.LinkageError: loader constraint violation: loader (instance of org/mobicents/slee/container/component/deployment/classloading/URLClassLoaderDomainImpl) previously initiated loading for a different type with name "jain/protocol/ip/mgcp/message/parms/CallIdentifier"

        at java.lang.ClassLoader.defineClass1(Native Method)

        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)

        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)

        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)

        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)

        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)

        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

        at org.mobicents.slee.container.component.deployment.classloading.URLClassLoaderDomainImpl.findClassLocallyLocked(URLClassLoaderDomainImpl.java:215)

        at org.mobicents.slee.container.component.deployment.classloading.URLClassLoaderDomainImpl.findClass(URLClassLoaderDomainImpl.java:184)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

        at org.mobicents.slee.container.component.deployment.classloading.URLClassLoaderDomainImpl.loadClass(URLClassLoaderDomainImpl.java:154)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

        at org.mobicents.protocols.mgcp.stack.JainMgcpStackProviderImpl.getUniqueCallIdentifier(JainMgcpStackProviderImpl.java:352)

        at org.mobicents.slee.resource.mgcp.ra.JainMgcpProviderImpl.getUniqueCallIdentifier(JainMgcpProviderImpl.java:210)

        at ch.peoplefone.pbx.call.CallSbb.createConfEndpointForMoh(CallSbb.java:592)

        at ch.peoplefone.pbx.call.CallSbb.placeOnHold(CallSbb.java:650)

        at ch.peoplefone.pbx.call.CallSbb.onCUpdateEvent(CallSbb.java:499)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.mobicents.slee.runtime.sbbentity.SbbEntityImpl.invokeEventHandler(SbbEntityImpl.java:481)

        at org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskImpl.routeQueuedEvent(EventRoutingTaskImpl.java:379)

        at org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskImpl.run(EventRoutingTaskImpl.java:126)

        at org.mobicents.slee.runtime.eventrouter.EventRouterExecutorImpl$EventRoutingTaskStatsCollector.run(EventRouterExecutorImpl.java:73)

        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:662)

10:2

 

Vilius Panevėžys

unread,
Jun 17, 2014, 5:38:56 AM6/17/14
to mobicent...@googlegroups.com
You might have multiple versions of the same library in classpath.


--
Vilius Panevėžys
Elitnet

David Salvador

unread,
Jun 17, 2014, 7:42:29 AM6/17/14
to mobicent...@googlegroups.com, vil...@elitnet.lt
I had the same problem.

Like Vilius said, you should have multiple versions of the same library in the classpath. also make sure you dont have any class with that name in your project ( that was my error, i overwride the project, but forgot to delete some old classes that had the same name).

David

Laurent Schweizer

unread,
Jun 18, 2014, 3:56:05 AM6/18/14
to mobicent...@googlegroups.com

Thanks for the info.

 

Before I never get such issue but since I move part of my code in a lib folder I get such error.

 

Did you think that  the following error is also due to the same issue?

 

09:48:09,624 ERROR [CallSbb] Failed to set sbb context

java.lang.ClassCastException: net.java.slee.resource.mgcp.MgcpActivityContextInterfaceFactoryImpl cannot be cast to net.java.slee.resource.mgcp.MgcpActivityContextInterfaceFactory

        at ch.peoplefone.pbx.call.CallSbb.setSbbContext(CallSbb.java:2167)

        at org.mobicents.slee.runtime.sbb.SbbObjectImpl.<init>(SbbObjectImpl.java:124)

        at org.mobicents.slee.runtime.sbb.SbbObjectPoolFactory.makeObject(SbbObjectPoolFactory.java:146)

        at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:974)

        at org.mobicents.slee.runtime.sbb.SbbObjectPoolImpl.borrowObject(SbbObjectPoolImpl.java:68)

        at org.mobicents.slee.runtime.sbbentity.SbbEntityImpl.assignSbbObject(SbbEntityImpl.java:740)

        at org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskImpl.routeQueuedEvent(EventRoutingTaskImpl.java:360)

        at org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskImpl.run(EventRoutingTaskImpl.java:126)

        at org.mobicents.slee.runtime.eventrouter.EventRouterExecutorImpl$EventRoutingTaskStatsCollector.run(EventRouterExecutorImpl.java:73)

        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:662)

 

BR

 

Laurent

 

De : mobicent...@googlegroups.com [mailto:mobicent...@googlegroups.com] De la part de David Salvador
Envoyé : mardi 17 juin 2014 13:42
À : mobicent...@googlegroups.com
Cc : vil...@elitnet.lt
Objet : Re: [mobicents-public] Error java.lang.LinkageError: loader constraint violation: loader

--
You received this message because you are subscribed to the Google Groups "mobicents-public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobicents-publ...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Oliver Jowett

unread,
Jun 18, 2014, 4:53:29 AM6/18/14
to mobicent...@googlegroups.com
On 18 June 2014 08:56, Laurent Schweizer <laurent....@peoplefone.com> wrote:

 

Did you think that  the following error is also due to the same issue?

 

09:48:09,624 ERROR [CallSbb] Failed to set sbb context

java.lang.ClassCastException: net.java.slee.resource.mgcp.MgcpActivityContextInterfaceFactoryImpl cannot be cast to net.java.slee.resource.mgcp.MgcpActivityContextInterfaceFactory


Yes this looks like the classic manifestation of having two copies of the class loaded (either from different locations, or twice from the same location by different classloaders).
The Factory interface visible in the FactoryImpl classloader is not the same (different classloader) as the Factory interface visible to your SBB code.

Oliver

David Salvador

unread,
Jun 19, 2014, 6:46:30 AM6/19/14
to mobicent...@googlegroups.com
I had the linkage Error exactly when i moved some of my code to a lib. If you haven't resolved that, if you're developing in one machine, and deploying on another (or VM), i would advice too:
  • to delete the entire folder of the project in the deployment machine
  • remove all the project jars from the repository,
  • copy the entire project once again  and deploy
About the Cast error, i agree that is the same error.

P.S:  if you're using maven, don't forget that when you add the dependency to your lib, you should use <scope>provided</scope>
Reply all
Reply to author
Forward
0 new messages