ClassFormatError: 56 while using hessian in j2me

浪尽此生 提交于 2019-12-18 09:07:14

问题


I am trying to use the hessian j2me implementation @ http://hessian.caucho.com/ using java me sdk 3.0.

http://hessian.caucho.com/doc/hessian-overview.xtp#Hessian%20Client%20for%20a%20cell-phone mentions the usage for j2me.

The application builds without any errors/warning. But, the moment the line where MicroHessianOutput is instantiated is hit, a ClassFormatError ( java.lang.Error: ClassFormatError: 56 ) is thrown.

Heres the trace :

TRACE: <at java.lang.Error: ClassFormatError:  56>, startApp threw an Exception
java.lang.Error: ClassFormatError:  56
 - alert.AlertDemo.showOption(), bci=26
 - alert.AlertDemo.startApp(), bci=9
 - javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
 - com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
 - com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
 - com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
 - com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
 - com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
 - com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

and heres showOption():

private void showOption () throws Exception{
       String url = "http://localhost/hello";

        HttpConnection c = (HttpConnection) Connector.open(url);

        c.setRequestMethod(HttpConnection.POST);

        OutputStream os = c.openOutputStream();
        MicroHessianOutput out = new MicroHessianOutput(os); //error throwing line
        /*
        out.startCall("hello");

        InputStream is = c.openInputStream();

        MicroHessianInput min = new MicroHessianInput(is);
        min.startReply();
        System.out.println(min.readString());
        */
    }

I have jdk 1.6u16 installed. I am thinking it might be because the classes in the library might have been written for an older jdk. I don't see any option in the IDE to configure this.

Here's the class source code: MicroHessianOutput

Any idea why this could be happening ?


回答1:


ClassFormatError happens when your JVM cannot load a class because it does not recognize it's format (e.g. JVM 1.4 trying to load class compiled by javac 1.5).

It's likely that J2ME requires an older target for classes. Try to recompile your Hessian stuff with

 javac -target 1.4 ...


来源:https://stackoverflow.com/questions/1688257/classformaterror-56-while-using-hessian-in-j2me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!