Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
821 views
in Technique[技术] by (71.8m points)

java - ClassFormatError: 56 while using hessian in j2me

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 ...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...