问题
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