Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-2188

java.lang.ClassNotFoundException on EJB 3.0 postactivate (SimpleStatefulCache) while doing HTTP Session Logout

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • None
    • core
    • None

    Description

      A java.lang.ClassNotFoundException: is thrown while doing an http session logout for the components which are passivated.

      java.lang.ClassNotFoundException: com.avaya.iptcm.cm.ui.station.SystemParameterBean
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
      2010-10-25 18:39:39,359 ERROR [STDERR] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
      2010-10-25 18:39:39,359 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
      2010-10-25 18:39:39,359 ERROR [STDERR] at java.lang.Class.forName(Class.java:247)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.io.JBossObjectInputStream.resolveClass(JBossObjectInputStream.java:141)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.io.JBossObjectInputStream$1.resolveClass(JBossObjectInputStream.java:127)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.classmetamodel.ClassMetamodelFactory.resolveClassByName(ClassMetamodelFactory.java:266)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.classmetamodel.ClassMetamodelFactory.getClassMetaData(ClassMetamodelFactory.java:289)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.classmetamodel.StreamingClass.readStream(StreamingClass.java:72)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:381)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectInput.readObject(DataContainer.java:643)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.persister.ArrayPersister.readObjectArray(ArrayPersister.java:196)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.persister.ArrayPersister.readData(ArrayPersister.java:172)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectInput.readObject(DataContainer.java:643)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.io.JBossObjectInputStream.readObjectOverride(JBossObjectInputStream.java:163)
      2010-10-25 18:39:39,359 ERROR [STDERR] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:345)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.serial.io.MarshalledObject.get(MarshalledObject.java:68)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulBeanContext.extractBeanAndInterceptors(StatefulBeanContext.java:793)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulBeanContext.getInterceptorInstances(StatefulBeanContext.java:781)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.interceptor.LifecycleInvocationContextImpl.getLifecycleInvocationContext(LifecycleInvocationContextImpl.java:65)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postActivate(LifecycleInterceptorHandler.java:143)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.invokePostActivate(StatefulContainer.java:409)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulBeanContext.postActivate(StatefulBeanContext.java:388)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.activateSession(StatefulSessionFilePersistenceManager.java:316)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:387)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:375)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:61)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulRemoveInterceptor.invoke(StatefulRemoveInterceptor.java:97)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:119)
      2010-10-25 18:39:39,359 ERROR [STDERR] at $Proxy2569.destroy(Unknown Source)
      2010-10-25 18:39:39,359 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor6125.invoke(Unknown Source)
      2010-10-25 18:39:39,359 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2010-10-25 18:39:39,359 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:43)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.javassist.tmp.java.lang.Object_$$javassist_seam_24.destroy(Object$$_javassist_seam_24.java)
      2010-10-25 18:39:39,359 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor6124.invoke(Unknown Source)
      2010-10-25 18:39:39,359 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2010-10-25 18:39:39,359 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.Component.callDestroyMethod(Component.java:2180)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.Component.destroy(Component.java:1469)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:251)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.contexts.Lifecycle.endSession(Lifecycle.java:295)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.contexts.ServletLifecycle.endSession(ServletLifecycle.java:160)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.servlet.SeamListener.sessionDestroyed(SeamListener.java:59)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.session.StandardSession.expire(StandardSession.java:702)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.session.StandardSession.expire(StandardSession.java:660)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.authenticator.SingleSignOn.deregister(SingleSignOn.java:528)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.authenticator.SingleSignOn.sessionEvent(SingleSignOn.java:333)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.session.StandardSession.fireSessionEvent(StandardSession.java:1604)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.session.StandardSession.expire(StandardSession.java:747)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.session.StandardSession.expire(StandardSession.java:660)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.session.StandardSession.invalidate(StandardSession.java:1111)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.session.StandardSessionFacade.invalidate(StandardSessionFacade.java:150)
      2010-10-25 18:39:39,359 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2010-10-25 18:39:39,359 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      2010-10-25 18:39:39,359 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2010-10-25 18:39:39,359 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.contexts.FacesLifecycle.invalidateSession(FacesLifecycle.java:158)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.contexts.FacesLifecycle.endRequest(FacesLifecycle.java:135)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.jsf.SeamPhaseListener.afterResponseComplete(SeamPhaseListener.java:525)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:253)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:196)
      2010-10-25 18:39:39,359 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
      2010-10-25 18:39:39,359 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      2010-10-25 18:39:39,359 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      2010-10-25 18:39:39,359 ERROR [STDERR] at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
      2010-10-25 18:39:39,360 ERROR [STDERR] at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
      2010-10-25 18:39:39,360 ERROR [STDERR] at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
      2010-10-25 18:39:39,360 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      2010-10-25 18:39:39,360 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      2010-10-25 18:39:39,360 ERROR [STDERR] at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)

      JBoss is throwing class not found exception in the postactivate task of JBOSS while doing the session logoff with SimpleStatefulCache. This is occuring while doing a logoff from the UI .The exact scenario to reproduce is as below.
      Step 1: Allow any bean to get passivated which is there in the HTTP Session context.
      Step 2: Do a log off from the UI.
      The logoff event is coming from UI is been intercepted by Stateful interceptors and try to destroy the session beans. At this time JBOSS is trying to remove the beans from the local cache which are not been passivated yet as well as the passivated beans. If the bean is passivated,it has to activate it before the removal task. For this it uses the activate method inside the corresponding cache implementation.

      Our cache configuration is SimpleStatefulCache. Now JBOSS actually has to deserialize the object which is serialized before as part of the passivate task.I will paste the passivate code snippet here to get it clarified.
      protected void passivate(StatefulBeanContext ctx)
      {
      ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
      try
      {
      Thread.currentThread().setContextClassLoader(((EJBContainer) ctx.getContainer()).getClassloader());
      pm.passivateSession(ctx);
      ++passivatedCount;
      }
      finally
      {
      Thread.currentThread().setContextClassLoader(oldCl);
      }
      }
      Here JBOSS sets the current class loader as the corresponding EJBContainer class loader before going for a serialization of the bean which is perfectly fine.
      But before doing a post activate method there is no code which sets the current class loader .There it is not require for the case in which the activate call comes from the same container contexts like corresponding applications web context.
      But when the HTTP Session timeout is getting dispatched from the root class loader which is the Webapp class loader (org.apache.catalina.loader.WebappClassLoader). Now the Individual applications class loaders are below this root class loader and the classes loader by these children are not available to the root according to classloader visibility and delegations principles. This makes the application to throw a ClassNotFoundException at this time.

      The issue is primarily with the class loader user while doing the operation. The classloader which is used while doing the normal serialization and deserialization of objects from UI is the WebContext class loader which has the access to all the beans loaded.

      While logout the class loader is org.apache.catalina.loader.WebappClassLoader which doesnot have the loaded beans.

      I have tried to fix this problem by setting the Classloader as the EJBContainer class loader before postactivate call and it worked.

      Fix Suggession from me :

      Create a static field in SimpleStatefulCache with type as HashMap(<String>,<ClassLoader>)

      The key is the StatefulBeanContext id's which are uniqely identifies the session beans. In the protected void passivate(StatefulBeanContext ctx) method put the ClassLoader evaluated from the expression (EJBContainer) ctx.getContainer()).getClassloader() to the map against the key ctx.getId() . On the get method of SimpleStatefulCache get the classLoader corresponding to this key before doing the activateSession() call.

      Keep the current classloader to a temp variable and set the classloader as the one which got from the map. Now , immediately after this call set the current thread classloader as the one stored in the temp variable.

      Remove the map entry on the remove method for cleaning memory.

      I have tried this and worked it.

      Attachments

        Activity

          People

            jaikiran Jaikiran Pai (Inactive)
            dhaneeshtnair Dhaneesh Nair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: