Discussions

EJB programming & troubleshooting: Getting a linkage error while accessing EJB in runtime

  1. Hi,

    I am getting the following exception while I try to access a stateful session EJB thats deployed on JBoss 5.0.1. Can someone help me fix this problem.

     

    2010-07-30 16:40:39,083 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http-127.0.0.1-8080-2) java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "$Proxy146.remove(Ljavax/ejb/Handle;)V" the class loader (instance of org/jboss/web/tomcat/service/WebCtxLoader$ENCLoader) of the current class, $Proxy146, and the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) for interface javax/ejb/EJBHome have different Class objects for the type javax/ejb/Handle used in the signature
    javax.faces.el.EvaluationException: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "$Proxy146.remove(Ljavax/ejb/Handle;)V" the class loader (instance of org/jboss/web/tomcat/service/WebCtxLoader$ENCLoader) of the current class, $Proxy146, and the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) for interface javax/ejb/EJBHome have different Class objects for the type javax/ejb/Handle used in the signature
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
        at javax.faces.component.UICommand.broadcast(UICommand.java:387)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.cgi.ncms.web.security.AuthorizationFilter.doFilter(AuthorizationFilter.java:118)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:905)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:592)
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2036)
        at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "$Proxy146.remove(Ljavax/ejb/Handle;)V" the class loader (instance of org/jboss/web/tomcat/service/WebCtxLoader$ENCLoader) of the current class, $Proxy146, and the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) for interface javax/ejb/EJBHome have different Class objects for the type javax/ejb/Handle used in the signature
        at java.lang.Class.getDeclaredFields0(Native Method)
        at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
        at java.lang.Class.getDeclaredField(Class.java:1880)
        at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1610)
        at java.io.ObjectStreamClass.access$700(ObjectStreamClass.java:52)
        at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:425)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:413)
        at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)
        at java.io.ObjectStreamClass.initProxy(ObjectStreamClass.java:507)
        at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1539)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
        at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:769)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.cgi.ncms.business.security.NcmsRemoteHelper.getNcmsDBRemoteBean(NcmsRemoteHelper.java:81)
        at com.cgi.ncms.business.security.NcmsAuthenticator.login(NcmsAuthenticator.java:130)
        at com.cgi.ncms.business.security.User.login(User.java:273)
        at com.cgi.ncms.web.security.Login.login(Login.java:147)
        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.apache.el.parser.AstValue.invoke(AstValue.java:170)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
        at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
        ... 32 more

    Thanks your time and help in advance.

  2. Linkage error usually comes when the application server tries to load classes from two class loading locations. eg: if we take an ear with a web application into consideration, if the same jar file (or class) is there in the ejb-jar and also WEB-INF/lib (or WEB-INF/classes) directory the you will get a linkage error.

    Just revvisit your deployed application and  confirm that you do not have the same class in two locations.