2

I'm trying to implement an existing XML parser: kXML.

I ran into the following error:

java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException
 at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
 at com.sun.midp.midlet.Scheduler.schedule(+52)
 at com.sun.midp.main.Main.runLocalClass(+28)
 at com.sun.midp.main.Main.main(+80)
Execution completed.

At this site you can find the error that I ran in to. The solution however doesn't work. I used the following script:

C:\WTK2.5.2_01\bin\preverify -classpath .;C:\java_libraries\wirelesstoolkit\midpapi20.jar org.kxml2.io.KXmlParser
C:\WTK2.5.2_01\bin\preverify -classpath .;C:\java_libraries\wirelesstoolkit\midpapi20.jar org.kxml2.io.KXmlSerializer
C:\WTK2.5.2_01\bin\preverify -classpath .;C:\java_libraries\wirelesstoolkit\midpapi20.jar org.xmlpull.v1.XmlPullParser
C:\WTK2.5.2_01\bin\preverify -classpath .;C:\java_libraries\wirelesstoolkit\midpapi20.jar org.xmlpull.v1.XmlPullParserException
C:\WTK2.5.2_01\bin\preverify -classpath .;C:\java_libraries\wirelesstoolkit\midpapi20.jar org.xmlpull.v1.XmlPullParserFactory
C:\WTK2.5.2_01\bin\preverify -classpath .;C:\java_libraries\wirelesstoolkit\midpapi20.jar org.xmlpull.v1.XmlSerializer

cd output

C:\Program Files\Java\jdk1.6.0_14\bin\jar -cvf ..\kxml2.jar org

I get the following errors (mutliple of these):

C:\Users\****\Desktop\kxmlfolder>C:\WTK2.5.2_01\bin\preverify -classpath .;C:\
java_libraries\wirelesstoolkit\midpapi20.jar org.kxml2.io.KXmlParser
Error preverifying class org.xmlpull.v1.XmlPullParser
    java/lang/NoClassDefFoundError: java/lang/Object

C:\Users\****\Desktop\kxmlfolder>C:\WTK2.5.2_01\bin\preverify -classpath .;C:\
java_libraries\wirelesstoolkit\midpapi20.jar org.kxml2.io.KXmlSerializer
Error preverifying class org.xmlpull.v1.XmlSerializer
    java/lang/NoClassDefFoundError: java/lang/Object

What can be the cause?

gnat
  • 6,213
  • 108
  • 53
  • 73
hsmit
  • 3,906
  • 7
  • 34
  • 46

5 Answers5

3

You problem is that you managed to configure your development environment to compile your MIDlet against the kXML libraries but your didn't include them into your MIDlet jar file so the J2ME emulator doesn't know how to find the classes your MIDlet imports at runtime.

michael aubert
  • 6,836
  • 1
  • 16
  • 32
1

Maybe you should include the kXml library. if you use eclipse MTJ, just right click on the project name, select properties, select Java Build Path in the list, in the right click select libraries, add external jar button, browse and select the kXml.jar file. You will see the new library now included. Try run the project again.

Ari R. Fikri
  • 331
  • 2
  • 11
  • I did so already. And eclipse finds the class and methods I want to call (auto import, auto completion etc). It's only when I run things it doesnt work.. – hsmit Jan 31 '10 at 17:03
  • 1. Have you tried to recreate new projects ? I supposed there's something to do with the build configuration file. Maybe you can post it here and someone will find out what's wrong. 2. Which version of eclipse and MTJ do you use ? Do you have netbeans ? If you create this project in Netbeans, is the same error happen ? – Ari R. Fikri Feb 02 '10 at 07:35
1

You need to link kxml-source in buildpath settings. I had a very hard time for 3 days to figure out this.

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
1

In eclipse just right click on the project name, select properties, select Java Build Path , go to ORDER & EXPORT and click on the external kXml jar file to be included alongwith the jar file of your project . This should work .

user699585
  • 11
  • 1
0

I hope my finding is somehow related: going through the XStream tutorial http://x-stream.github.io/tutorial.html I got the same error message. I found out that I had to include kxml2-[version].jar (given in the bundle) and not the kxml2-min-[version].jar, as stated in the tutorial. So following what QuickRecipesOnSymbian said, I think including the correct jar is crucial.

facundofarias
  • 2,973
  • 28
  • 27