2 Replies Latest reply on Feb 16, 2007 10:25 AM by Jeff Smith

    Remoting via mbean issue

    Jeff Smith Newbie

      We are attempting to deploy a Jboss Remoting Server as an mbean using JBossRemoting-2_0_0_GA on Jboss-4.0.4 jdk1.5.

      We have used the following classes provided in the tests package as is:


      org.jboss.test.remoting.handler.mbean.service.ClientTest:

      public class ClientTest {
       private static String transport = "socket";
       private static String host = "localhost";
       private static int port = 5400;
       public void makeInvocation(String locatorURI) throws Throwable {
       InvokerLocator locator = new InvokerLocator(locatorURI);
       System.out.println("Calling remoting server with locator uri of: " + locatorURI);
       Client remotingClient = new Client(locator);
       remotingClient.connect();
       Object response = remotingClient.invoke("Do something");
       System.out.println("Invocation response: " + response);
       }
       public static void main(String[] args) {
       if(args != null && args.length == 2) {
       transport = args[0];
       port = Integer.parseInt(args[1]);
       }
       String locatorURI = transport + "://" + host + ":" + port;
       ClientTest clientTest = new ClientTest();
       try {
       clientTest.makeInvocation(locatorURI);
       }
       catch(Throwable e) {
       e.printStackTrace();
       }
       }
      }
      


      org.jboss.test.remoting.handler.mbean.MBeanHandler:
      public class MBeanHandler implements MBeanHandlerMBean {
       private MBeanServer server = null;
       private ServerInvoker invoker = null;
       public void setMBeanServer(MBeanServer server) {
       this.server = server;
       }
       public void setInvoker(ServerInvoker invoker) {
       this.invoker = invoker;
       }
       public Object invoke(InvocationRequest invocation) throws Throwable {
       System.out.println(invocation.getParameter());
       return ServerTest.RESPONSE_VALUE;
       }
       public void addListener(InvokerCallbackHandler callbackHandler) { }
       public void removeListener(InvokerCallbackHandler callbackHandler) { }
       void create() throws Exception { }
       void start() throws Exception { }
       void stop() { }
       void destroy() { }
      }
      



      mbeanhandler-service.xml:
      <server>
       <classpath codebase="lib" archives="*"/>
       <mbean code="org.jboss.remoting.network.NetworkRegistry"
       name="jboss.remoting:service=NetworkRegistry"/>
       <mbean code="org.jboss.remoting.samples.simple.MBeanHandler"
       name="test:type=handler"/>
       <mbean code="org.jboss.remoting.transport.Connector"
       xmbean-dd="org/jboss/remoting/transport/Connector.xml"
       name="jboss.remoting:service=Connector,transport=Socket"
       display-name="Socket transport Connector">
       <attribute name="Configuration">
       <config>
       <invoker transport="socket">
       <attribute name="numAcceptThreads">1</attribute>
       <attribute name="maxPoolSize">303</attribute>
       <attribute name="clientMaxPoolSize" isParam="true">304</attribute>
       <attribute name="socketTimeout">60000</attribute>
       <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
       <attribute name="serverBindPort">5400</attribute>
       <attribute name="enableTcpNoDelay" isParam="true">false</attribute>
       <attribute name="backlog">200</attribute>
       </invoker>
       <handlers>
       <handler subsystem="test">test:type=handler</handler>
       </handlers>
       </config>
       </attribute>
       </mbean>
      </server>
      


      The mbean deploys as expected, however when we run the client we receive the following:

      Client Side:
       [java] Calling remoting server with locator uri of: socket://localhost:5400
       [java] Invoking server with request of 'Do something'
       [java] 10:53:50,634 [ERROR] org.jboss.remoting.transport.socket.SocketClientInvoker: Got marshalling exception, exiting
       [java] java.net.SocketException
       [java] at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:348)
       [java] at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:116)
       [java] at org.jboss.remoting.Client.invoke(Client.java:612)
       [java] at org.jboss.remoting.Client.invoke(Client.java:604)
       [java] at org.jboss.remoting.Client.invoke(Client.java:589)
       [java] at org.jboss.remoting.samples.simple.SimpleClient.makeInvocation(Unknown Source)
       [java] at org.jboss.remoting.samples.simple.SimpleClient.main(Unknown Source)
       [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       [java] at java.lang.reflect.Method.invoke(Method.java:585)
       [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:202)
       [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:134)
       [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
       [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
       [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
       [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
       [java] at org.apache.tools.ant.Task.perform(Task.java:364)
       [java] at org.apache.tools.ant.Target.execute(Target.java:341)
       [java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
       [java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
       [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
       [java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
       [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
       [java] at org.apache.tools.ant.Main.runBuild(Main.java:668)
       [java] at org.apache.tools.ant.Main.startAnt(Main.java:187)
       [java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
       [java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
       [java] java.rmi.MarshalException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
       [java] java.net.SocketException
       [java] at org.jboss.remoting.transport.socket.SocketClientInvoker.handleException(SocketClientInvoker.java:118)
       [java] at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:400)
       [java] at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:116)
       [java] at org.jboss.remoting.Client.invoke(Client.java:612)
       [java] at org.jboss.remoting.Client.invoke(Client.java:604)
       [java] at org.jboss.remoting.Client.invoke(Client.java:589)
       [java] at org.jboss.remoting.samples.simple.SimpleClient.makeInvocation(Unknown Source)
       [java] at org.jboss.remoting.samples.simple.SimpleClient.main(Unknown Source)
      


      Server Side:
      10:53:50,618 DEBUG [ServerThread] beginning dorun
      10:53:50,618 ERROR [ServerThread] failed to process invocation.
      java.io.OptionalDataException
       at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1310)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
       at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
       at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
       at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:350)
       at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:398)
       at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
      10:53:50,618 DEBUG [ServerThread] begin thread wait
      10:53:50,618 DEBUG [ServerThread] WAKEUP in SERVER THREAD
      


      Is there anything we are overlooking? Any assistance is greatly appreciated.


        • 1. Re: Remoting via mbean issue
          Tom Elrod Master

          I just did a checkout of JBossRemoting (tag remoting_2_0_0_GA) and built the jboss-remoting.jar and jboss-remoting-tests.jar (this jar contains the MBeanHandler classes) using the tests.jars ant target. Then copied both jars into server/default/lib directory of JBossAS 4.0.4.GA. Then created a mbeanhandler-service.xml containing following and put in deploy directory:

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE server>
          
          <!-- ======================================================== -->
          <!-- Example JBoss Remoting Service Configuration file -->
          <!-- ======================================================== -->
          <server>
          
           <!-- NOTE: set this up to the path where your libraries are -->
           <classpath codebase="lib"
           archives="*"/>
          
           <mbean code="org.jboss.remoting.network.NetworkRegistry"
           name="jboss.remoting:service=NetworkRegistry"/>
          
           <!-- MBean Server Invocation Handler -->
           <mbean code="org.jboss.test.remoting.handler.mbean.MBeanHandler"
           name="test:type=handler"/>
          
          
           <mbean code="org.jboss.remoting.transport.Connector"
           name="jboss.remoting:service=Connector,transport=Socket"
           display-name="Socket transport Connector">
          
           <!-- Can either just specify the InvokerLocator attribute and not the invoker element in the -->
           <!-- Configuration attribute, or do the full invoker configuration in the in invoker element -->
           <!-- of the Configuration attribute. -->
          
           <!-- Remember that if you do use more than one param on the uri, will have to include as a CDATA, -->
           <!-- otherwise, parser will complain. -->
           <!-- <attribute name="InvokerLocator"><![CDATA[socket://${jboss.bind.address}:8084/?enableTcpNoDelay=false&clientMaxPoolSize=30]]></attribute>-->
          
           <attribute name="Configuration">
           <config>
           <invoker transport="socket">
           <attribute name="numAcceptThreads">1</attribute>
           <attribute name="maxPoolSize">303</attribute>
           <attribute name="clientMaxPoolSize" isParam="true">304</attribute>
           <attribute name="socketTimeout">60000</attribute>
           <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
           <attribute name="serverBindPort">5400</attribute>
           <!-- <attribute name="clientConnectAddress">216.23.33.2</attribute> -->
           <!-- <attribute name="clientConnectPort">7777</attribute> -->
           <attribute name="enableTcpNoDelay" isParam="true">false</attribute>
           <attribute name="backlog">200</attribute>
           </invoker>
           <handlers>
           <handler subsystem="test">test:type=handler</handler>
           </handlers>
           </config>
           </attribute>
          
           </mbean>
          
          
          </server>
          
          


          Then ran the org.jboss.test.remoting.handler.mbean.ClientTest under the jboss remoting project and everything worked.

          The only thing I saw based on what you posted is that your mbeanhandler-service.xml file should not have deployed with remoting 2.0.0.GA because your Connector mbean contained the following:

          xmbean-dd="org/jboss/remoting/transport/Connector.xml"
          


          So I'm guessing either the service deployment failed or are not really using remoting 2.0.0 jar file. May also want to verify your client is also using 2.0.0 jar.

          • 2. Re: Remoting via mbean issue
            Jeff Smith Newbie

            Thank you very much, Tom!

            It seems that this line did not matter in our deployment.

            xmbean-dd="org/jboss/remoting/transport/Connector.xml"
            


            The key was that we were not using the JbossRemoting-2.0.0.jar

            Our bad. Thanks.


            For anyone making the same mistake:
            JbossAS-4.0.5-GA ships with jboss-remoting.jar-1.4.5.
            One should replace that with jboss-remoting.jar-2.0.0 from the JBossRemoting-2_0_0_GA download.