2 Replies Latest reply on Aug 10, 2007 3:02 AM by ron_sigal

    Un/Marshaller not found

    hurzeler

      I am trying to have a socket server accepting plain text. I defined my service as:

      <server>
       <mbean code="org.jboss.remoting.transport.Connector"
       name="jboss.remoting:service=Connector,transport=Socket"
       display-name="Socket transport Connector">
       <attribute name="Configuration">
      
       <config>
      
       <invoker transport="socket">
       <!-- The following are specific to socket invoker -->
       <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">8084</attribute>
       <attribute name="enableTcpNoDelay" isParam="true">false</attribute>
       <attribute name="backlog">200</attribute>
       <attribute name="datatype" isParam="true">invocation</attribute>
       <attribute name="marshaller" isParam="true">com.test.socket.V75SocketServer.TextMarshaller</attribute>
       <attribute name="unmarshaller" isParam="true">com.test.socket.V75SocketServer.TextUnMarshaller</attribute>
       <attribute name="serverSocketClass">com.test.socket.V75SocketServer.SimpleInputStreamWrapper</attribute>
       </invoker>
      
       <handlers>
       <handler subsystem="V75">com.test.socket.V75SocketServer.Handler</handler>
       </handlers>
       </config>
       </attribute>
      
       </mbean>
      </server>
      


      on deployment I get the following on the server:
      Invoker started for locator: InvokerLocator [socket://x.x.x.x:8084/?clientMaxPoolSize=304&datatype=invocation&enableTcpNoDelay=false&marshaller=com.test.socket.V75SocketServer.TextMarshaller&unmarshaller=com.test.socket.V75SocketServer.TextUnMarshaller]
      

      When I debug I see that my SimpleInputStreamWrapper is used but my marshaller/unmarshaller is not and I subsequently get the following exception:
      23:13:00,031 ERROR [ServerThread] failed to process invocation.
      java.io.StreamCorruptedException: invalid stream header
       at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:764)
       at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277)
       at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.<init>(ObjectInputStreamWithClassLoader.java:73)
       at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.createInput(JavaSerializationManager.java:52)
       at org.jboss.remoting.serialization.SerializationManager.createRegularInput(SerializationManager.java:44)
       at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:123)
       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)
      

      What am I missing? Please Help!

        • 1. Re: Un/Marshaller not found
          hurzeler

          Please help I am really stuck.

          I use JBoss 4.0.5GA with Jboss remoting 1.4.0. The question is how do I get the socket server configured so that it accepts simple text. I have created three extra classes SimpleInputStreamWrapper which just returns the input and outputstreams and the two marshallers like:

          package com.test.socket.V75SocketServer;
          
          import java.io.BufferedReader;
          import java.io.IOException;
          import java.io.InputStream;
          import java.io.InputStreamReader;
          import java.io.Reader;
          import java.util.Map;
          
          import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
          
          /**
           * @author hurzeler
           *
           */
          public class TextUnMarshaller extends SerializableUnMarshaller
          {
          
           /**
           *
           */
           private static final long serialVersionUID = -5026128440188409051L;
          
           /**
           *
           */
          
           public TextUnMarshaller(){}
          
           @Override
           public Object read(InputStream is, Map map) throws IOException, ClassNotFoundException
           {
           StringBuffer buffer = new StringBuffer();
           try {
           InputStreamReader isr = new InputStreamReader(is, "UTF8");
           Reader in = new BufferedReader(isr);
           int ch;
           while ((ch = in.read()) > -1) {
           buffer.append((char)ch);
           }
           in.close();
           return buffer.toString();
           } catch (IOException e) {
           e.printStackTrace();
           return null;
           }
          
           }
          
          }


          However the un/marshaller gets never called.
          Please help!!!

          Thanks

          • 2. Re: Un/Marshaller not found
            ron_sigal

            Sorry for the long delay in answering.

            When attempting to load a marshaller, org.jboss.remoting.marshal.MarshalFactory will first try to use the value of the datatype parameter, "invocation" in this case. Since "invocation" is not a built-in data type, there would be no marshaller associated with "invocation" unless you explicitly made the connection by calling MarshalFactory.addMarshaller(). Did you do that? If not, that's ok, since it will then look in the InvokerLocator for the fully qualified name of a marshaller. So, in your case, it should create an instance of com.test.socket.V75SocketServer.TextMarshaller. I don't know why it isn't. Could you run your application with TRACE logging turned on to see if there are any messages concerning the marshaller?