6 Replies Latest reply on Apr 5, 2007 11:28 AM by brian.stansberry

    java.io.NotSerializableException: WebappClassLoader

    philippe.suray

      Hello,

      I would like to use TreeCache inside JBossAS and access it from Tomcat running outside JBossAS.
      - JBoss 4.0.5 GA
      - Tomcat 5.5.20
      - WinXP
      - j2sdk1.5.0_07

      I have a cache-service.xml config in the deploy directory of JBoss, here is the config:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!-- ===================================================================== -->
      <!-- -->
      <!-- Sample TreeCache Service Configuration -->
      <!-- -->
      <!-- ===================================================================== -->
      
      <server>
      
       <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
      
      
       <!-- ==================================================================== -->
       <!-- Defines TreeCache configuration -->
       <!-- ==================================================================== -->
      
       <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache">
       <depends>jboss:service=Naming</depends>
       <depends>jboss:service=TransactionManager</depends>
      
       <!-- Configure the TransactionManager -->
       <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
      
       <!--
       Node locking level : SERIALIZABLE
       REPEATABLE_READ (default)
       READ_COMMITTED
       READ_UNCOMMITTED
       NONE
       -->
       <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
      
       <!--
       Valid modes are LOCAL
       REPL_ASYNC
       REPL_SYNC
       INVALIDATION_ASYNC
       INVALIDATION_SYNC
       -->
       <attribute name="CacheMode">LOCAL</attribute>
      
       <!--<attribute name="UseInterceptorMbeans">true</attribute>-->
      
       <!-- Name of cluster. Needs to be the same for all clusters, in order
       to find each other
       -->
       <attribute name="ClusterName">TreeCache-Cluster</attribute>
      
       <!-- JGroups protocol stack properties. Can also be a URL,
       e.g. file:/home/bela/default.xml
       <attribute name="ClusterProperties"></attribute>
       -->
      
       <attribute name="ClusterConfig">
       <config>
       <!-- UDP: if you have a multihomed machine,
       set the bind_addr attribute to the appropriate NIC IP address -->
       <!-- UDP: On Windows machines, because of the media sense feature
       being broken with multicast (even after disabling media sense)
       set the loopback attribute to true -->
       <UDP mcast_addr="228.1.2.3" mcast_port="48866"
       ip_ttl="64" ip_mcast="true"
       mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
       ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
       loopback="false"/>
       <PING timeout="2000" num_initial_members="3"
       up_thread="false" down_thread="false"/>
       <MERGE2 min_interval="10000" max_interval="20000"/>
       <FD shun="true" up_thread="true" down_thread="true"/>
       <VERIFY_SUSPECT timeout="1500"
       up_thread="false" down_thread="false"/>
       <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
       max_xmit_size="8192" up_thread="false" down_thread="false"/>
       <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
       down_thread="false"/>
       <pbcast.STABLE desired_avg_gossip="20000"
       up_thread="false" down_thread="false"/>
       <FRAG frag_size="8192"
       down_thread="false" up_thread="false"/>
       <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
       shun="true" print_local_addr="true"/>
       <pbcast.STATE_TRANSFER up_thread="false" down_thread="false"/>
       </config>
       </attribute>
      
      
       <!--
       The max amount of time (in milliseconds) we wait until the
       initial state (ie. the contents of the cache) are retrieved from
       existing members in a clustered environment
       -->
       <attribute name="InitialStateRetrievalTimeout">20000</attribute>
      
       <!--
       Number of milliseconds to wait until all responses for a
       synchronous call have been received.
       -->
       <attribute name="SyncReplTimeout">20000</attribute>
      
       <!-- Max number of milliseconds to wait for a lock acquisition -->
       <attribute name="LockAcquisitionTimeout">15000</attribute>
      
      
       <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
       <!-- Specific eviction policy configurations. This is LRU -->
       <attribute name="EvictionPolicyConfig">
       <config>
       <attribute name="wakeUpIntervalSeconds">300</attribute>
       <!-- Cache wide default -->
      
       <region name="/command_image/">
       <attribute name="maxNodes">100</attribute>
       <attribute name="timeToLiveSeconds">8</attribute>
       <attribute name="maxAgeSeconds">10</attribute>
       </region>
      
       <region name="/command_photo/">
       <attribute name="maxNodes">100</attribute>
       <attribute name="timeToLiveSeconds">8</attribute>
       <attribute name="maxAgeSeconds">10</attribute>
       </region>
      
       <region name="/command_mixte/">
       <attribute name="maxNodes">100</attribute>
       <attribute name="timeToLiveSeconds">8</attribute>
       <attribute name="maxAgeSeconds">10</attribute>
       </region>
       </config>
       </attribute>
      
      
       <!--
       Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped
       class loader, e.g., inside an application server. Default is "false".
       -->
       <attribute name="UseRegionBasedMarshalling">true</attribute>
       <attribute name="CacheLoaderConfiguration">
       <config>
       <passivation>true</passivation>
       <preload></preload>
       <cacheloader>
       <class>org.jboss.cache.loader.JDBCExtendedCacheLoader</class>
       <!-- same as the old CacheLoaderConfig attribute -->
       <properties>
       cache.jdbc.table.name=jbosscache
       cache.jdbc.table.create=true
       cache.jdbc.table.drop=false
       cache.jdbc.table.primarykey=jbosscache_pk
       cache.jdbc.fqn.column=fqn
       cache.jdbc.fqn.type=varchar(255)
       cache.jdbc.node.column=node
       cache.jdbc.node.type=VARBINARY(MAX)
       cache.jdbc.parent.column=parent
       cache.jdbc.driver=net.sourceforge.jtds.jdbc.Driver
       cache.jdbc.url=jdbc:jtds:sqlserver://192.168.1.74:1433/MappingCache
       cache.jdbc.user
       cache.jdbc.password
       </properties>
       <!-- whether the cache loader writes are asynchronous -->
       <async>false</async>
       <!-- only one cache loader in the chain may set fetchPersistentState to true.
       An exception is thrown if more than one cache loader sets this to true. -->
       <fetchPersistentState>true</fetchPersistentState>
       <!-- determines whether this cache loader ignores writes - defaults to false. -->
       <ignoreModifications>false</ignoreModifications>
       <!-- if set to true, purges the contents of this cache loader when the cache starts up.
       Defaults to false. -->
       <purgeOnStartup>false</purgeOnStartup>
       </cacheloader>
       </config>
       </attribute>
       </mbean>
      
       <mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
       name="mydomain:service=proxyFactory,type=jrmp,target=factory">
       <attribute name="InvokerName">jboss:service=invoker,type=jrmp</attribute>
       <attribute name="TargetName">jboss.cache:service=TreeCache</attribute>
       <attribute name="JndiName">MyCache</attribute>
       <attribute name="InvokeTargetMethod">true</attribute>
       <attribute name="ExportedInterface">org.jboss.cache.TreeCacheMBean</attribute>
       <attribute name="ClientInterceptors">
       <interceptors>
       <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
       <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
       <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
       </interceptors>
       </attribute>
       <depends>jboss:service=invoker,type=jrmp</depends>
       <depends>jboss.cache:service=TreeCache</depends>
       </mbean>
      </server>
      


      In Tomcat, i can bind to the TreeCache with jndi in my ServletContextListener. But when Tomcat execute this line
      treecache.registerClassLoader("/command_image/", Thread.currentThread().getContextClassLoader());
      

      an exception is thrown:
      ERROR 2007-04-04 17:49:54,078 com.marketip.cache.util.TreeCacheSingleton -
      java.lang.reflect.UndeclaredThrowableException
       at $Proxy0.registerClassLoader(Unknown Source)
       at com.marketip.cache.util.TreeCacheSingleton.init(TreeCacheSingleton.java:45)
       at com.marketip.cache.listener.CacheControlListener.contextInitialized(CacheControlListener.java:39)
       at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
       at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904)
       at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)
       at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
       at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
       at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
       at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
       at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
       at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
       at org.apache.catalina.core.StandardService.start(StandardService.java:450)
       at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
       at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
       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:585)
       at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
      Caused by: java.rmi.MarshalException: error marshalling arguments; nested exception is:
       java.io.NotSerializableException: org.apache.catalina.loader.WebappClassLoader
       at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
       at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
       at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:133)
       at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365)
       at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197)
       at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
       at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)
       at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
       ... 27 more
      Caused by: java.io.NotSerializableException: org.apache.catalina.loader.WebappClassLoader
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
       at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
       at org.jboss.invocation.MarshalledValue.<init>(MarshalledValue.java:70)
       at org.jboss.invocation.MarshalledInvocation.createMarshalledValue(MarshalledInvocation.java:632)
       at org.jboss.invocation.MarshalledInvocation.writeExternal(MarshalledInvocation.java:570)
       at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1307)
       at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1288)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
       at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:258)
       at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:117)
       ... 34 more
      


      Here is the complete code executed in order to bind to TreeCache:
      Properties props = new Properties();
       props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
       props.setProperty("java.naming.provider.url", "jnp://localhost:1099");
       props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       InitialContext ctx=new InitialContext(props);
       treecache = (TreeCacheMBean)ctx.lookup("MyCache");
       treecache.registerClassLoader("/command_image/", Thread.currentThread().getContextClassLoader());
       isInited = true;
      


      Could someone help me?
      What is wrong in my config or in my code?

      Thank you in advance.

      PHS

        • 1. Re: java.io.NotSerializableException: WebappClassLoader
          brian.stansberry

          You can't execute the registerClassloader method remotely; a classloader is not meant to be serialized.

          Why do you want to use that method from the Tomcat server?

          • 2. Re: java.io.NotSerializableException: WebappClassLoader
            philippe.suray

            I have a web app that serves images to a client. I want that these images are put in the cache. My idea is to run Jboss in order to manage the cache and Tomcat in front of JBoss to put and retreive images.
            Could it be possible?

            Could you explain me the reason of the example at chapter 8.2.1? I have copied and adapted this example?

            I also try to deploy my webapp in Tomcat inside JBoss and i have also an exception

            08:59:28,406 INFO [STDOUT] 08:59:28,390 ERROR [TreeCacheSingleton]
            java.lang.reflect.UndeclaredThrowableException
             at $Proxy52.registerClassLoader(Unknown Source)
             at com.marketip.cache.util.TreeCacheSingleton.init(TreeCacheSingleton.java:41)
             at com.marketip.cache.listener.CacheControlListener.contextInitialized(CacheControlListener.java:39)
             at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3763)
             at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211)
             at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
             at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
             at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
             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:585)
             at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
             at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.apache.catalina.core.StandardContext.init(StandardContext.java:5052)
             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:585)
             at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
             at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:297)
             at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:103)
             at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:371)
             at org.jboss.web.WebModule.startModule(WebModule.java:83)
             at org.jboss.web.WebModule.startService(WebModule.java:61)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
             at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
             at $Proxy0.start(Unknown Source)
             at org.jboss.system.ServiceController.start(ServiceController.java:417)
             at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy37.start(Unknown Source)
             at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
             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:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
             at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
             at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInterceptor.java:92)
             at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
             at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy38.start(Unknown Source)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
             at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy8.deploy(Unknown Source)
             at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
             at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
             at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
             at $Proxy0.start(Unknown Source)
             at org.jboss.system.ServiceController.start(ServiceController.java:417)
             at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.in
            08:59:28,406 INFO [STDOUT] voke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy4.start(Unknown Source)
             at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
             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:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy5.deploy(Unknown Source)
             at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
             at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
             at org.jboss.Main.boot(Main.java:200)
             at org.jboss.Main$1.run(Main.java:490)
             at java.lang.Thread.run(Thread.java:595)
            Caused by: java.rmi.MarshalException: error marshalling arguments; nested exception is:
             java.io.NotSerializableException: org.jboss.web.tomcat.tc5.WebAppClassLoader
             at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
             at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
             at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:133)
             at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365)
             at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197)
             at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
             at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)
             at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
             ... 138 more
            Caused by: java.io.NotSerializableException: org.jboss.web.tomcat.tc5.WebAppClassLoader
             at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
             at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
             at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
             at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
             at org.jboss.invocation.MarshalledValue.<init>(MarshalledValue.java:70)
             at org.jboss.invocation.MarshalledInvocation.createMarshalledValue(MarshalledInvocation.java:632)
             at org.jboss.invocation.MarshalledInvocation.writeExternal(MarshalledInvocation.java:570)
             at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1307)
             at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1288)
             at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
             at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
             at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:258)
             at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:117)
             ... 145 more
            


            If i understand correctly, i cannot use a cache configured with a cacheloader, if the cache run outside my webapp? Is it right ?

            Thank for your response.

            PHS


            • 3. Re: java.io.NotSerializableException: WebappClassLoader
              philippe.suray

              I ran another test: deploy my webapp in Tomcat inside JBoss, in my ServletContextListener i init the cache with:

              MBeanServer server =MBeanServerLocator.locateJBoss();
              treecache = (TreeCacheMBean)MBeanProxyExt.create(TreeCacheMBean.class, "jboss.cache:service=TreeCache", server);
              treecache.registerClassLoader("/command_image/", Thread.currentThread().getContextClassLoader());
              isInited = true;


              In my servlet, i try to get an image from the cache with:
              (MappingResponse)treeCache.get(fqn.toString(), key))


              Another exception is thrown:
              10:12:06,437 ERROR [JDBCCacheLoader] Failed to load node for fqn /command_image/style_20/zoom_10/grid_10_127: Unable to load to deserialize result: java.lang.ClassNotFoundException: No ClassLoaders found for: com.marketip.cache.util.MappingResponse
              java.sql.SQLException: Unable to load to deserialize result: java.lang.ClassNotFoundException: No ClassLoaders found for: com.marketip.cache.util.MappingResponse
               at org.jboss.cache.loader.JDBCCacheLoader.loadNode(JDBCCacheLoader.java:1109)
               at org.jboss.cache.loader.JDBCCacheLoader.get(JDBCCacheLoader.java:263)
               at org.jboss.cache.interceptors.CacheLoaderInterceptor.loadData(CacheLoaderInterceptor.java:443)
               at org.jboss.cache.interceptors.CacheLoaderInterceptor.loadNode(CacheLoaderInterceptor.java:353)
               at org.jboss.cache.interceptors.CacheLoaderInterceptor.invoke(CacheLoaderInterceptor.java:180)
               at org.jboss.cache.interceptors.ActivationInterceptor.invoke(ActivationInterceptor.java:64)
               at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
               at org.jboss.cache.interceptors.UnlockInterceptor.invoke(UnlockInterceptor.java:32)
               at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
               at org.jboss.cache.interceptors.TxInterceptor.handleNonTxMethod(TxInterceptor.java:365)
               at org.jboss.cache.interceptors.TxInterceptor.invoke(TxInterceptor.java:160)
               at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
               at org.jboss.cache.interceptors.CacheMgmtInterceptor.invoke(CacheMgmtInterceptor.java:138)
               at org.jboss.cache.TreeCache.invokeMethod(TreeCache.java:5863)
               at org.jboss.cache.TreeCache.get(TreeCache.java:3627)
               at org.jboss.cache.TreeCache.get(TreeCache.java:3608)
               at org.jboss.cache.TreeCache.get(TreeCache.java:3595)
               at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
               at $Proxy54.get(Unknown Source)
               at com.marketip.cache.filter.CacheFilter.doFilter(CacheFilter.java:54)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
               at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
               at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
               at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
               at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
               at java.lang.Thread.run(Thread.java:595)


              I really don't understand what happens.

              Help, help ...

              PHS

              • 4. Re: java.io.NotSerializableException: WebappClassLoader
                brian.stansberry

                The problem is that since you're invoking via the JMX server, the thread context classloader gets switched when you call get() to one that doesn't know about your classes.

                Fortunately, JBoss Cache has a hack built in that lets you get around the problem. It lets you get ahold of the actual TreeCache instance via the mbean proxy. Once you've done that you can directly invoke on the TreeCache and you shouldn't have this problem.

                MBeanServer server = MBeanServerLocator.locateJBoss();
                TreeCacheMBean mbeanProxy = (TreeCacheMBean)MBeanProxyExt.create(TreeCacheMBean.class, "jboss.cache:service=TreeCache", server);
                treecache = mbeanProxy.getInstance();
                treecache.registerClassLoader("/command_image/", Thread.currentThread().getContextClassLoader());
                isInited = true;


                • 5. Re: java.io.NotSerializableException: WebappClassLoader
                  philippe.suray

                  Thank you for your response. I tried it but unfortunately i have another exception:

                  17:09:20,937 INFO [STDOUT] 17:09:20,921 ERROR [TreeCacheSingleton] org.jboss.cache.TreeCache
                  java.lang.ClassCastException: org.jboss.cache.TreeCache
                   at $Proxy52.getInstance(Unknown Source)
                   at com.marketip.cache.util.TreeCacheSingleton.init(TreeCacheSingleton.java:30)
                   at com.marketip.cache.listener.CacheControlListener.contextInitialized(CacheControlListener.java:38)
                   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3763)
                   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211)
                   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
                   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
                   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
                   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:585)
                   at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
                   at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                   at org.apache.catalina.core.StandardContext.init(StandardContext.java:5052)
                   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:585)
                   at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
                   at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                   at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:297)
                   at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:103)
                   at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:371)
                   at org.jboss.web.WebModule.startModule(WebModule.java:83)
                   at org.jboss.web.WebModule.startService(WebModule.java:61)
                   at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                   at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                   at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:585)
                   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                   at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                   at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                   at $Proxy0.start(Unknown Source)
                   at org.jboss.system.ServiceController.start(ServiceController.java:417)
                   at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:585)
                   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                   at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                   at $Proxy37.start(Unknown Source)
                   at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
                   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:585)
                   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                   at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
                   at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
                   at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInterceptor.java:92)
                   at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
                   at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
                   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                   at $Proxy38.start(Unknown Source)
                   at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
                   at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:585)
                   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                   at $Proxy8.deploy(Unknown Source)

                  It's very strange because the cause is this line:
                  treecache = mbeanProxy.getInstance();

                  I've just copy your code.

                  PHS

                  • 6. Re: java.io.NotSerializableException: WebappClassLoader
                    brian.stansberry

                    Make sure there's only one copy of jboss-cache.jar on the classpath. Don't package it in your webapp; it's already on the server classpath (in server/all/lib).