1 Reply Latest reply: Sep 6, 2010 7:56 AM by 843849 RSS

    hessian + creme 4.12

    843849
      Hi,

      I've been struggling with getting Hessian (4.0.3) to work on a device running creme 4.12 (arm architecture).
      I'm using netbeans 6.8 and the code's working if I'm running it by using the emulator.

      When I run the same test program on the remote vm (the connected device), it throws an exception.

      Client code:
       String url = "http://192.168.1.7:8080/WebApplication1/BasicService";
      
                  HttpConnection c = (HttpConnection) Connector.open(url);
                  c.setRequestMethod(HttpConnection.POST);
                  c.setRequestProperty("content-type","x-application/hessian");
                  
                  OutputStream os = c.openOutputStream();
                  MicroHessianOutput out = new MicroHessianOutput(os);
      
                  out.startCall("hello");
                  out.writeString("3552AGNH");
                  out.completeCall();
                  //os.flush();
      
                  InputStream is = c.openInputStream();
      
                  MicroHessianInput in = new MicroHessianInput(is);
                  in.startReply();
                  String result = in.readString();
                  JOptionPane.showMessageDialog(this, result);
                  in.completeReply();
      Servlet code:
      public class BasicService extends HessianServlet
      {
          public String hello(String artCode)
          {
              return "result: " + artCode;
          }
      }
      Exception thrown when the code is run in the remote VM:
      NSIcom Ltd., CrEme(tm) Evaluation Version
      CrE-ME J2ME(tm)
      CrE-ME V4.12.26 B160.081109 8-November-2009
        MemoryLimit=28608Kb
      EBCI(TM) Interpreter V1.00,
      Copyright 1998-2002 by Bytecodes, Inc.
      java.io.IOException: expected string at end of file
           at com.caucho.hessian.micro.MicroHessianInput.protocolException()
           at com.caucho.hessian.micro.MicroHessianInput.expect()
           at com.caucho.hessian.micro.MicroHessianInput.readString()
           at be.carglass.main.Main.test()
           at be.carglass.main.Main.btnNewCrateActionPerformed()
           at be.carglass.main.Main.access$000()
           at be.carglass.main.Main$2.actionPerformed()
           at javax.swing.AbstractButton.fireActionPerformed()
           at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed()
           at javax.swing.DefaultButtonModel.fireActionPerformed()
           at javax.swing.DefaultButtonModel.setPressed()
           at javax.swing.plaf.basic.BasicButtonListener.mouseReleased()
           at java.awt.Component.processMouseEvent()
           at java.awt.Component.processEvent()
           at java.awt.Container.processEvent()
           at java.awt.Component.dispatchEventImpl()
           at java.awt.Container.dispatchEventImpl()
           at java.awt.Component.dispatchEvent()
           at java.awt.LightweightDispatcher.retargetMouseEvent()
           at java.awt.LightweightDispatcher.processMouseEvent()
           at java.awt.LightweightDispatcher.dispatchEvent()
           at java.awt.Container.dispatchEventImpl()
           at java.awt.Window.dispatchEventImpl()
           at java.awt.Component.dispatchEvent()
           at java.awt.EventDispatchThread.run()
      Does anyone know how I can resolve this issue?

      Looking forward to your replies.

      Edited by: sirdeaz on Apr 5, 2010 12:02 AM

      Edited by: sirdeaz on Apr 5, 2010 12:14 AM
        • 1. Re: hessian + creme 4.12
          843849
          Hi sirdeaz,

          I have used hessian 3.1.5, and work fine, in production environment.
          Tomcat + Windows Mobile + Creme 4.12.

          Points:
          - Do you, in the server side, create a Interface, like sample in documentation? Even if not used in the mobile, its necessary.

          - How do you configure your web.xml?
          Its necessary set the servlet-name, like:

          <servlet-name>WSSample</servlet-name>
          <servlet-class>br.com.sample.BasicService</servlet-class>
          </servlet>

          and, I create too the servlet-mapping, like:
          <servlet-mapping>
          <url-pattern>/test</url-pattern>
          <servlet-name>WSSample</servlet-name>
          </servlet-mapping>

          and, the url in mobile, with this conficurations, i set like:

          http://ip:8084/br.com.sample.WebService/test

          where br.com.sample.WebService, just the name of the .war, that deployed.


          - I don't use the line (c.setRequestProperty("content-type","x-application/hessian");). its not necessary.
          - And, you comment the line
          out.startCall("hello");
          out.writeString("3552AGNH");
          out.completeCall();
          //os.flush();
          I use this line. And in the end, I use too:
          is.close();
          os.close();
          c.close();

          First, review your interface in the server. The .jar from interface project does not need copy for the mobile, does not need reference, ans classpath. But its necessary in the server side.

          thanks,
          Fábio Pinheiro

          Edited by: FabioPinheiro on Sep 6, 2010 5:51 AM