2 Replies Latest reply on Feb 6, 2008 10:50 PM by nlaney

    NoClassDefFoundError using Eclipse/JUnit

    nlaney

      hello, I'm accessing a WS running on JBoss 4.2.2 using JBossWS 2.0.3

      I've generated the service artifacts using wsconsume and I'm getting a NoClassDefFoundError running the client code as a JUnit or Java app.

      The same test runs OK from the command line using wsrunclient, or at least when copying the generated cmd line string into a cmd prompt, and it works when running the test during the Maven build lifecycle.

      I would like to be able to run the tests in the Eclipse WTP 2.0 workbench. Any help would be appreciated. The test is just a basic HelloWorld, and the stacktrace is:

      java.lang.NoClassDefFoundError: com/sun/xml/messaging/saaj/soap/AttachmentPartImpl
      at com.sun.xml.ws.message.AttachmentUnmarshallerImpl.(AttachmentUnmarshallerImpl.java:55)
      at com.sun.xml.ws.client.sei.ResponseBuilder$DocLit.readResponse(ResponseBuilder.java:500)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:242)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
      at $Proxy25.findAll(Unknown Source)
      at org.MyTest.test(MyTest.java:38)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at junit.framework.TestCase.runTest(TestCase.java:164)
      at junit.framework.TestCase.runBare(TestCase.java:130)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:120)
      at junit.framework.TestSuite.runTest(TestSuite.java:230)
      at junit.framework.TestSuite.run(TestSuite.java:225)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Caused by: java.lang.ClassNotFoundException: com.sun.xml.messaging.saaj.soap.AttachmentPartImpl
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClassInternal(Unknown Source)
      ... 25 more

      Paste stack traces into this console and follow hyperlinks to source code.

        • 1. Re: NoClassDefFoundError using Eclipse/JUnit
          nlaney

          A bit of additional information, the classpath for the JUnit run configuration are set the same as the command line classpath.

          TIA, if anyone is able to help with this problem!

          • 2. SOLUTION: NoClassDefFoundError using Eclipse/JUnit
            nlaney

            Problem: wsclientrun sets the classpath in the command line and runs OK. Run/Debug/Junit threw NoClassDefFoundError with the stacktrace in the previous post. The classpath was set on the classpath tab.

            Solution: use the same command line arguments as wsclientrun in the JVM arguments field of the arguments tab to set the classpath.

            Note: it was necessary to copy the output of wsclientrun and make some changes to the classpath argument, to include bin;output which are the class folders for the test class and the wsconsume generated classes.

            Run/Debug/Junit all run without errors!