1 Reply Latest reply on Feb 8, 2006 7:22 AM by tremalnaik

    MarshalException while invoking remote MBean

    tremalnaik

      Hi, I deployed a MBean which implements the HASingleton in a clusterd JBoss application. I use it to manage a HashMap userd to read/store user infos. I followed the instructions found here:

      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=55794

      So I think the configuration is fine, because trying the service on a single-server cluster it works fine. Problems arise when I start a 2nd server. The MBean definition follows:

      public class LicenseSingletonService extends ServiceMBeanSupport implements
       LicenseSingletonServiceMBean
      {
       private Map sessions;
      
       public LicenseSingletonService()
       {
       sessions = new HashMap();
       }
      
       public Map getUserSessions()
       {
       return sessions;
       }
      
       public void setUserSessions(Map sessions)
       {
       this.sessions = sessions;
       }
      
       public void startSingleton()
       {
       }
      
       public void stopSingleton()
       {
       }
      
      }


      The MBean is invoked inside a Valve, which intercepts user requests and stores session infos in a HashMap:

      public class LicenseRequirementsValve extends ValveBase
      {
      
       private MBeanServerConnection singletonService;
      
       private Map sessions;
      
       ........


      The adaptor is initiallized in the LicenseRequirementsValve constructor:

      public LicenseRequirementsValve() throws Exception
      {
       // initialize the singleton service
       Hashtable jndiProperties = new Hashtable();
       jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,
       "org.jnp.interfaces.NamingContextFactory");
       jndiProperties.put(Context.PROVIDER_URL, "localhost:1100");
       jndiProperties.put("java.naming.factory.url.pkgs",
       "org.jboss.naming:org.jnp.interfaces");
       Context context = new InitialContext(jndiProperties);
       this.singletonService = (MBeanServerConnection) context.lookup("jmx/invoker/SingletonRMIAdaptor");
       if ((singletonService != null)
       && (singletonService.isRegistered(new ObjectName(
       "licenseSingletonService.mbean:service=LicenseSingletonService"))))
       {
       LogHelper.logMessage("Singleton service found");
       }
       .........
      

      The map is read/written by means of the LicenseRequirementsValve methods:

      private Map getSessionsFromRemoteSingleton() throws ReflectionException,
       InstanceNotFoundException, MBeanException, IOException, MalformedObjectNameException
      {
       Map sMap = (Map) singletonService.invoke(new ObjectName(
       "licenseSingletonService.mbean:service=LicenseSingletonService"),
       "getUserSessions", new Object[0], new String[0]);
       return sMap;
      }


      and

      private void updateSessionsToRemoteSingleton() throws ReflectionException,
       InstanceNotFoundException, MBeanException, IOException, MalformedObjectNameException
      {
       singletonService.invoke(new ObjectName("licenseSingletonService.mbean:service=LicenseSingletonService"),
       "setUserSessions", new Object[] { this.sessions },
       new String[] { "java.util.HashMap" });
      }


      The exception is thrown calling the latest:

      09:50:06,898 ERROR [ROM] [USER: claves] java.rmi.MarshalException: error marshalling arguments; nested exception is:
       java.io.NotSerializableException: com.bitaplus.bitastar.web.valve.LicenseRequirementsValve
       at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
       at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
       at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:118)
       at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:227)
       at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:167)
       at org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor.invoke(InvokerAdaptorClientInterceptor
      .java:51)
       at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
       at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:59)
       at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
       at $Proxy51.invoke(Unknown Source)
       at com.ciccio.pasticcio.web.valve.LicenseRequirementsValve.updateSessionsToRemoteSingleton(LicenseRequirementsV
      alve.java:211)
       at com.ciccio.pasticcio.web.valve.LicenseRequirementsValve.invoke(LicenseRequirementsValve.java:416)
       at com.ciccio.pasticcio.web.valve.LoginErrorMessageValve.invoke(LoginErrorMessageValve.java:33)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)


      I really can't see where is my mistake. Can you help me, please?

      TREMALNAIK

        • 1. Re: MarshalException while invoking remote MBean
          tremalnaik

          I forgot to say:

          1) if this is the wrong place to post my question please tell me.

          2) I understand the error is due the fact that I didn't declare the valve Serializable, but I DON'T want to do it. Infact I want the only object be marshalled is the HashMap that I'm trying to write to the remote object

          Thanks