4 Replies Latest reply on Jul 9, 2018 11:04 AM by pferraro

    ClassNotFoundExpection during Session replication when using custom class loaders

    eddiecarpenter

      We are busy migrating our system from Glassfish onto Wildfly 10.1 and are experiencing a problem with the Session replication.

      The system is deployed as an EAR and can be extended at runtime using plugins. The plugins are loaded using an URLClassLoader (using the  ModuleClassLoader as parent). The loading (and reloading) of the plugins works 100% and there is no issue expect for when the session is failover to another host. All the classes loaded from plugins fails to be de-marshalled and generates a ClassNotFoundExpection.

       

      Any assistance in resolving the above would be greatly appreciated!

       

      The Setup

      The environment consists of 2 hosts and a domain controller which also acts as a load balancer.

      The setup was done on the following the examples Stuart Douglas post at modcluster-example/clustering-domain-mode.txt at master · stuartwdouglas/modcluster-example · GitHub  and information found in Clustering and Domain Setup Walkthrough - WildFly 10 - Project Documentation Editor .

      The setup was tested using Stuart Douglas' clustering example and failover works 100%

       

      The Problem

      The initial investigation found that when the session is de-marshalled, the marshalling engine is it not aware that some of the classes were loaded using a different class loader. It looks like the marshaller is instantiated on startup  and could we not find any way to change the class loader used for the de-marshalling process.

       

      The following stack trace is generated:

      WFLYCLWEBINF0007: Failed to activate attributes of session jRF38FQqWMwHNo5ZEdbhtrpPAo_0OzHSrgIfov4K: org.wildfly.clustering.marshalling.jboss.InvalidSerializedFormException: java.lang.ClassNotFoundException: org.tradeswitch.insurance.InsuranceCommissionCtrl

        at org.wildfly.clustering.marshalling.jboss.MarshalledValueMarshaller.read(MarshalledValueMarshaller.java:47)

        at org.wildfly.clustering.marshalling.jboss.MarshalledValueMarshaller.read(MarshalledValueMarshaller.java:32)

        at org.wildfly.clustering.web.infinispan.session.coarse.CoarseSessionAttributesFactory.findValue(CoarseSessionAttributesFactory.java:79)

        at org.wildfly.clustering.web.infinispan.session.coarse.CoarseSessionAttributesFactory.findValue(CoarseSessionAttributesFactory.java:48)

        at org.wildfly.clustering.web.infinispan.session.InfinispanSessionFactory.findValue(InfinispanSessionFactory.java:61)

        at org.wildfly.clustering.web.infinispan.session.InfinispanSessionFactory.findValue(InfinispanSessionFactory.java:38)

        at org.wildfly.clustering.web.infinispan.session.InfinispanSessionManager.findSession(InfinispanSessionManager.java:233)

        at org.wildfly.clustering.web.undertow.session.DistributableSessionManager.getSession(DistributableSessionManager.java:148)

        at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:772)

        at io.undertow.servlet.spec.HttpServletRequestImpl.getSession(HttpServletRequestImpl.java:370)

        at org.jboss.weld.servlet.SessionHolder.requestInitialized(SessionHolder.java:47)

        at org.jboss.weld.servlet.HttpContextLifecycle.requestInitialized(HttpContextLifecycle.java:234)

        at org.jboss.weld.servlet.WeldInitialListener.requestInitialized(WeldInitialListener.java:152)

        at io.undertow.servlet.core.ApplicationListeners.requestInitialized(ApplicationListeners.java:246)

        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:291)

        at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)

        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)

        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)

        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)

        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)

        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)

        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)

        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)

        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

        at java.lang.Thread.run(Thread.java:745)