3 Replies Latest reply on Jan 17, 2011 5:55 AM by Petr H

    NotSerializableException exception on WorkManager

    Leon Feijtel Newbie

      Hello,

       

      I'm trying to port an application running on JBoss 4.04 to JBoss 6 CR1.

       

      So far this has been going quite well. The few issues that I ran into were easily solved. But today I ran into a problem which I haven't been able to resolve.

       

      The application makes use of a WorkManager to delegate tasks to. But during deployment, when the WorkManager is resolved, I get an exception.

       

      15:43:32,192 ERROR [JBossWorkManager] Error occurred trying to create a new JBoss WorkManager instance: : java.lang.reflect.UndeclaredThrowableException
          at $Proxy182.getInstance(Unknown Source)    at com.myapp.workmanager.JBossWorkManager.<init>(JBossWorkManager.java:41) [:]
          at com.myapp.workmanager.WorkManagerFactory.createNewWorkManager(WorkManagerFactory.java:43) [:]
          at com.myapp.workmanager.WorkManagerFactory.getWorkManager(WorkManagerFactory.java:53) [:]
          at com.myapp.context.AutostartListener.start(AutostartListener.java:98) [:]
          at com.myapp.context.AutostartListener.contextInitialized(AutostartListener.java:56) [:]
          at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3369) [:6.0.0.20101110-CR1]
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:3828) [:6.0.0.20101110-CR1]
          at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:312) [:6.0.0.20101110-CR1]
          at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:149) [:6.0.0.20101110-CR1]
          at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461) [:6.0.0.20101110-CR1]
          at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118) [:6.0.0.20101110-CR1]
          at org.jboss.web.deployers.WebModule.start(WebModule.java:95) [:6.0.0.20101110-CR1]
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_22]
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [:1.6.0_22]
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [:1.6.0_22]
          at java.lang.reflect.Method.invoke(Unknown Source) [:1.6.0_22]
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157) [:6.0.0.Beta5]
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96) [:6.0.0.Beta5]
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) [:6.0.0.Beta5]
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:271) [:6.0.0.Beta5]
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:670) [:6.0.0.Beta5]
          at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206) [:2.2.0.Alpha10]
          at $Proxy41.start(Unknown Source)    at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:53) [:2.2.0.Alpha10]
          at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:41) [:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:301) [:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:894) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:641) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:182) [:2.2.0.Alpha8]
          at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:58) [:2.2.0.Alpha8]
          at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) [:2.2.0.Alpha8]
          at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55) [:2.2.0.Alpha8]
          at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.0.Alpha8]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2.2.0.Alpha8]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [:2.2.0.Alpha8]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1571) [:2.2.0.Alpha8]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1603) [:2.2.0.Alpha8]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2.2.0.Alpha8]
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.0.Alpha8]
          at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.0.Alpha8]
          at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.0.Alpha8]
          at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.0.0.20101110-CR1]
          at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:130) [:0.1.0.Alpha1]
          at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:148) [:0.1.0.Alpha1]
          at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.1.0.Alpha1]
          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.Alpha10]
          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.Alpha10]
          at org.jboss.profileservice.dependency.ProfileServiceController.activate(ProfileServiceController.java:188) [:0.1.0.Alpha1]
          at org.jboss.profileservice.AbstractProfileService.activateProfile(AbstractProfileService.java:170) [:0.1.0.Alpha1]
          at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:117) [:0.1.0.Alpha1]
          at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:89) [:0.1.0.Alpha1]
          at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:97) [:0.1.0.Alpha1]
          at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:130) [:6.0.0.20101110-CR1]
          at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.0.0.20101110-CR1]
          at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
          at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]
          at java.lang.Thread.run(Unknown Source) [:1.6.0_22]
      Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
          java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.jboss.resource.work.JBossWorkManager
          at sun.rmi.server.UnicastRef.invoke(Unknown Source) [:1.6.0_22]
          at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source) [:1.6.0_22]
          at javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttribute(Unknown Source) [:1.6.0_22]
          at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(Unknown Source) [:1.6.0_22]
          at javax.management.MBeanServerInvocationHandler.invoke(Unknown Source) [:1.6.0_22]
          ... 86 more
      Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.jboss.resource.work.JBossWorkManager
          at java.io.ObjectInputStream.readObject0(Unknown Source) [:1.6.0_22]
          at java.io.ObjectInputStream.readObject(Unknown Source) [:1.6.0_22]
          at sun.rmi.server.UnicastRef.unmarshalValue(Unknown Source) [:1.6.0_22]
          ... 91 more
      Caused by: java.io.NotSerializableException: org.jboss.resource.work.JBossWorkManager
          at java.io.ObjectOutputStream.writeObject0(Unknown Source) [:1.6.0_22]
          at java.io.ObjectOutputStream.writeObject(Unknown Source) [:1.6.0_22]
          at sun.rmi.server.UnicastRef.marshalValue(Unknown Source) [:1.6.0_22]
          at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) [:1.6.0_22]
          at sun.rmi.transport.Transport$1.run(Unknown Source) [:1.6.0_22]
          at java.security.AccessController.doPrivileged(Native Method) [:1.6.0_22]
          at sun.rmi.transport.Transport.serviceCall(Unknown Source) [:1.6.0_22]
          at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) [:1.6.0_22]
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source) [:1.6.0_22]
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source) [:1.6.0_22]
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [:1.6.0_22]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [:1.6.0_22]
          ... 1 more

       

       

      This is the code that is being executed (the workMember variable is a class member):

       

      try {
         Context jndiContext = new InitialContext();
         MBeanServerConnection mconn = (MBeanServerConnection) jndiContext.lookup("jmx/invoker/RMIAdaptor");
         ObjectName objectName = new ObjectName("jboss.jca:service=WorkManager");

       

         JBossWorkManagerMBean jwm = (JBossWorkManagerMBean)

                 MBeanServerInvocationHandler.newProxyInstance(mconn,objectName, JBossWorkManagerMBean.class, false)

                 

         workManager = jwm.getInstance();

       

      } catch(Exception e) {

         ...

      }

       

      I am not very familiar with JMX or the WorkManager. Can anyone point me in the right direction on how to solve this issue?


      Any help would be greatly appreciated.


      Thanks!


        • 1. Re: NotSerializableException exception on WorkManager
          Leon Feijtel Newbie

          I think I've found a solution myself, searching through various websites.

           

          In de code sample I provided, I used a jndi lookup. When replaced by MBeanServerLocator.locateJBoss(), the code runs fine. This obviously because serialization isn't needed anymore now that I do not use the RMIAdaptor anymore.

           

          Hope this helps others. The work code sample is:

          MBeanServer mconn = MBeanServerLocator.locateJBoss();

          ObjectName objectName = new ObjectName("jboss.jca:service=WorkManager");
          JBossWorkManagerMBean jwm = (JBossWorkManagerMBean)
          MBeanServerInvocationHandler.newProxyInstance(mconn,objectName,JBossWorkManagerMBean.class,false);
          workmanager = jwm.getInstance();
          • 2. NotSerializableException exception on WorkManager
            Petr H Newbie

            Hi,

            we seem to have bumped into the same problem when using Spring (3.0.5) bean org.springframework.jca.work.jboss.JBossWorkManagerTaskExecutor for accessing the work manager where pretty much the same (JNDI) approach is applied.

             

            The question of interest is whether the current state in JBoss 6 is intended or not - so which code has to be changed to fix this - Spring or JBoss?

            Note that the above mentioned "fix" also introduces a direct dependency on JBoss code which might be not that good thing for a framework such as Spring.

            • 3. Re: NotSerializableException exception on WorkManager
              Petr H Newbie

              Spring's (3.0.5) org.springframework.jca.work.jboss.JBossWorkManagerUtils uses the following code:

               

              {code}private static final String JBOSS_WORK_MANAGER_MBEAN_CLASS_NAME = "org.jboss.resource.work.JBossWorkManagerMBean";

              private static final String MBEAN_SERVER_CONNECTION_JNDI_NAME = "jmx/invoker/RMIAdaptor";

              ...

                 Class<?> mbeanClass = JBossWorkManagerUtils.class.getClassLoader().loadClass(JBOSS_WORK_MANAGER_MBEAN_CLASS_NAME);

                 InitialContext jndiContext = new InitialContext();

                 MBeanServerConnection mconn = (MBeanServerConnection) jndiContext.lookup(MBEAN_SERVER_CONNECTION_JNDI_NAME);

                 ObjectName objectName = ObjectName.getInstance(mbeanName);

                 Object workManagerMBean = MBeanServerInvocationHandler.newProxyInstance(mconn, objectName, mbeanClass, false);

                 Method getInstanceMethod = workManagerMBean.getClass().getMethod("getInstance");

                 return (WorkManager) getInstanceMethod.invoke(workManagerMBean);{code}

              which we then changed into something like:

              {code}import org.jboss.mx.util.MBeanServerLocator;

              ...

              private static final String JBOSS_WORK_MANAGER_MBEAN_CLASS_NAME = "org.jboss.resource.work.JBossWorkManagerMBean";

              ...

                 Class<?> mbeanClass = JBossWorkManagerUtils.class.getClassLoader().loadClass(JBOSS_WORK_MANAGER_MBEAN_CLASS_NAME);

                 MBeanServer mconn = MBeanServerLocator.locateJBoss();

                 ObjectName objectName = ObjectName.getInstance(mbeanName);

                 Object workManagerMBean = MBeanServerInvocationHandler.newProxyInstance(mconn, objectName, mbeanClass, false);

                 Method getInstanceMethod = workManagerMBean.getClass().getMethod("getInstance");

                 return (WorkManager) getInstanceMethod.invoke(workManagerMBean);{code}

              but this of course introduces a dependency on the JBoss code from within the Spring code and thus we don't think this is the "correct" solution.

              Is there any proposal on anything which wouldn't require that dependency while still maintaining the functionality?

              If not then we think the JBoss code will have to be changed to let it working via the JNDI approach.

               

              EDIT: Created an issue for this: https://issues.jboss.org/browse/JBAS-8806