1 Reply Latest reply: Aug 24, 2009 6:10 AM by 843849 RSS

    build fails with java.lang.NoClassDefFoundError: javax.xml.stream.XMLStream

    843849
      Hi,

      I am trying to develope a sample application on NetBeans 6.7.1 (inbuilt JavaME 3.0) for JSR280 XML api as per [http://www.netbeans.org/kb/docs/javame/cdc-quickstart.html]

      Successfully done NetBeans CDC Emulator Platform Setup for [http://www.netbeans.org/kb/docs/javame/cdcemulator-setup.html]
      - CrEme VM for Windows CE
      - Microsoft Device Emulator
      - ActiveSync

      when I run application Main.java with default "Hello World" code, it succesfully run with "Hello World" display in both Emulator platform, CDC Java(TM) Platform Micro Edition SDK 3.0 and pJSCP V4.12 B142.190301

      When I change Main.java to use JSR280 javax.xml.stream.XMLOutputFactory and javax.xml.stream.XMLStreamWriter, it gave me red compilation error. So I did below steps and get rid of Netbeans compilation error
      (1) Project-->Properties-->Manage Emulatore
      (2) Select Platform "CDC Java(TM) Platform Micro Edition SDK 3.0" and click on 'Add JAR/Folder' to add C:\java\netbeans6.7.1\mobility8\Java_ME_platform_SDK_3.0\lib\jsr280_1.0.jar
      (3) Select Platform "pJSCP V4.12 B142.190301" and click on 'Add JAR/Folder' to add C:\java\netbeans6.7.1\mobility8\Java_ME_platform_SDK_3.0\lib\jsr280_1.0.jar

      NetBeans recognized javax.xml.stream.XMLOutputFactory and javax.xml.stream.XMLStreamWriter classes and red compilation error disappered.

      When I run application Main.java again, it gave me below exception in NetBeans output panel
      nsicom-run:
      ODT agent stopped.
      java.lang.NoClassDefFoundError: javax.xml.stream.XMLStreamWriter
      at java.lang.Class.getMethod0(Native Method)
      at java.lang.Class.getDeclaredMethod(Class.java:1247)
      at com.sun.cdc.odt.CdcAppManager.runMain(CdcAppManager.java:169)
      at com.sun.cdc.odt.CdcAppManager.access$100(CdcAppManager.java:44)
      at com.sun.cdc.odt.CdcAppManager$1.run(CdcAppManager.java:90)
      at java.lang.Thread.startup(Thread.java:782)
      cdc-hi-run:
      profiler.check:
      open-profiler:
      run:
      BUILD SUCCESSFUL (total time: 3 seconds)

      Any kind of help would be highly appreciated.

      Thanks in advance.
        • 1. Re: build fails with java.lang.NoClassDefFoundError: javax.xml.stream.XMLStream
          843849

          After spending few hours I found the solution :)


          (1) Goto Project Properties-->Build-->Library & Resources-->Add Jar/Zip-->select C:\java\netbeans6.7.1\mobility8\Java_ME_platform_SDK_3.0\lib\jsr280_1.0.jar
          (2) Now you need to copy JSR-280.jsr file to the Emulator runtime environment. So copy same file and paste it to C:\java\netbeans6.7.1\mobility8\Java_ME_platform_SDK_3.0\runtimes\cdc-hi\lib\ext
          (3) Copy your XML file and paste it to same location C:\java\netbeans6.7.1\mobility8\Java_ME_platform_SDK_3.0\runtimes\cdc-hi\library.xml
          (4) In your java program use File path as just "library.xml"


          Cheers !