JUnit NoClassDefFoundError

186 views
Skip to first unread message

Ian Bambury

unread,
Apr 20, 2007, 7:22:58 AM4/20/07
to Google-We...@googlegroups.com
It doesn't seem to matter what I do, I still get this error.
 
I have the simplest of test cases

public void test1()
{
assertEquals(true, true);
}

which JUnit finds and reports the error as shown below.

Since I have no idea what I am doing, I'm having a bit of trouble fixing it.

Any ideas, folks?

Cheers,
Ian
 
 
 
 
java.lang.NoClassDefFoundError: com/google/gwt/dev/GWTShell
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClass(Unknown Source)
 at java.security.SecureClassLoader.defineClass (Unknown Source)
 at java.net.URLClassLoader.defineClass(Unknown Source)
 at java.net.URLClassLoader.access$000(Unknown Source)
 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)
 at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:177)
 at junit.framework.TestCase.runBare(TestCase.java:127)
 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:118)
 at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:114)
 at junit.framework.TestSuite.runTest(TestSuite.java:208)
 at junit.framework.TestSuite.run(TestSuite.java:203)
 at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run (JUnit3TestReference.java:128)
 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)

 



--
Ian
http://roughian.com

Steiner Dominik, (QX59311)

unread,
Apr 20, 2007, 7:42:24 AM4/20/07
to Google-We...@googlegroups.com

Hi Ian,

 

I’m not sure what might be the problem, but my first guess was if you have gwt-dev-windows.jar on your classpath?

 

Dominik

 


Ian Bambury

unread,
Apr 20, 2007, 8:20:20 AM4/20/07
to Google-We...@googlegroups.com
Hi Dominik,
 
On my classpath I have:
 
JRE
src
the default classpath
- project
- gwt-user.jar
- JUNIT_HOME/junit.jar
junit.jar (3.8.1)
gwt-dev-windows.jar
 
in

getModuleName()

I have the same as the gwt:module in the html file - with or without the '.gwt.xml' I get the same error

and to run it all I right-click and choose run as JUnit Test

Thanks for you help,

Ian



On 20/04/07, Steiner Dominik, (QX59311) <Dominik...@partner.bmw-motorsport.com> wrote:

Hi Ian,

 

I'm not sure what might be the problem, but my first guess was if you have gwt-dev-windows.jar on your classpath?

 

Dominik

 


Von: Google-We...@googlegroups.com [mailto:Google-We...@googlegroups.com] Im Auftrag von Ian Bambury
Gesendet: Freitag, 20. April 2007 13:23
An: Google-We...@googlegroups.com
Betreff: JUnit NoClassDefFoundError

 

It doesn't seem to matter what I do, I still get this error.
 
I have the simplest of test cases

public void test1()
{
assertEquals(true, true);
}

which JUnit finds and reports the error as shown below.

Since I have no idea what I am doing, I'm having a bit of trouble fixing it.

Any ideas, folks?

Cheers,
Ian

 

 

 

 

java.lang.NoClassDefFoundError: com/google/gwt/dev/GWTShell
 at java.lang.ClassLoader.defineClass1(Native Method)

 at java.lang.ClassLoader.defineClass (Unknown Source)


 at java.security.SecureClassLoader.defineClass (Unknown Source)
 at java.net.URLClassLoader.defineClass(Unknown Source)
 at java.net.URLClassLoader.access$000(Unknown Source)

 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)
 at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:177)

 at junit.framework.TestCase.runBare (TestCase.java:127)


 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:118)


 at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:114)
 at junit.framework.TestSuite.runTest(TestSuite.java:208)
 at junit.framework.TestSuite.run(TestSuite.java:203)
 at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run (JUnit3TestReference.java:128)
 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)




--
Ian
http://roughian.com

Steiner Dominik, (QX59311)

unread,
Apr 20, 2007, 8:31:14 AM4/20/07
to Google-We...@googlegroups.com

Hi Ian,

 

I just tried out and removed gwt-dev-windows.jar from my project classpath and I got the same exception as you did.

 

If you’re using eclipse you might go to the debug perspective and make a right mouse click on the test you have run (the RemoteTestRunner entry) and select properties. There you see the classpath. Perhaps you can check that the gwt-dev-windows.jar is in there.

 

Hope you can find the problem soon. J

Ian Bambury

unread,
Apr 20, 2007, 8:45:12 AM4/20/07
to Google-We...@googlegroups.com
Brilliant! Fixed it. I was looking at the .launch file
 
So where is the JUnit classpath defined then? I found it in Eclipse, of course, but where is it on disk?
 
Anyway, thanks again, who knows how much time you have just saved me :-)
 
Ian

 

 at junit.framework.TestResult.run (TestResult.java:109)


 at junit.framework.TestCase.run ( TestCase.java:118)
 at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:114)
 at junit.framework.TestSuite.runTest(TestSuite.java:208)

 at junit.framework.TestSuite.run (TestSuite.java:203)


 at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run (JUnit3TestReference.java:128)
 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)

 



--
Ian
http://roughian.com



 

 




--
Ian
http://roughian.com







--
Ian
http://roughian.com

Steiner Dominik, (QX59311)

unread,
Apr 20, 2007, 8:54:15 AM4/20/07
to Google-We...@googlegroups.com

Hi Ian,

 

great to hear that you could solve your problem.

 

Normally when I write a GWTTestCase I write the java class and then execute the test. The test will fail like this, of course.

So I go to Run -> Debug… and select the test launch config on the left and go to the classpath tab. There I add the src folder and my test folder where my test classes are.

 

Eclipse by default adds the project classpath to the test launch config, so if you already have the gwt jars already added to your project, it should work.

 

Well, that’s how I do it at least. J There might be better solutions out there.

 

Anyway, good to hear that you were able to solve it. It was my pleasure. J

Ian Bambury

unread,
Apr 20, 2007, 9:20:09 AM4/20/07
to Google-We...@googlegroups.com
Yep. Moved on to the next error message :-)
 

[ERROR] Unable to find type 'com.domain_name.subdomain_name.client.Application_StartFile'

But this is progress
 


 
On 20/04/07, Steiner Dominik, (QX59311) <Dominik...@partner.bmw-motorsport.com> wrote:

Hi Ian,

 

great to hear that you could solve your problem.

 

Steiner Dominik, (QX59311)

unread,
Apr 20, 2007, 9:31:53 AM4/20/07
to Google-We...@googlegroups.com

Hi Ian,

 

I’m sorry to hear that you triped on sth else now. L

 

Perhaps this tip might help you. Here my structure is that I have a separate test folder under my project.

 

So

 

/bin

/src

/test

 

In test I have the same package structure as under src, so eg. test/com/foo/bar/client

 

If I want to test the class Blubber.java which is under src/com/foo/bar/client/Blubber.java I create a test class under test/com/foo/bar/client/BlubberTest.java

 

I also create a gwt.xml test file under test/com/foo/bar/client/Test.gwt.xml

 

In my test class I have

 

      public String getModuleName() {

            return "com.foo.bar.client.Test";

      }

 

The test module gwt file might look like

 

<module>

  <inherits name='com.google.gwt.user.User'/>

</module>

 

So I don’t define any entry point, as I don’t want to test that the application starts up ok. In my test class I have a method which tests the object I want to test

 

      public void testOptionsType() throws Exception {

            DefaultGDialog dlg = new DefaultGDialog();

            dlg.setOptions(GDialog.OK_CANCEL_OPTION_TYPE, null);

            assertEquals(dlg.getOptionType(), GDialog.OK_CANCEL_OPTION_TYPE);

      }

 

In your classpath you have to add the gwt jars, the src folder and the test folder.

 

I hope that this might help you getting started successfully. J

 

Dominik

 

 


Von: Google-We...@googlegroups.com [mailto:Google-We...@googlegroups.com] Im Auftrag von Ian Bambury
Gesendet: Freitag, 20. April 2007 15:20
An: Google-We...@googlegroups.com
Betreff: Re: JUnit NoClassDefFoundError

 

Yep. Moved on to the next error message :-)

Ian Bambury

unread,
Apr 20, 2007, 9:35:33 AM4/20/07
to Google-We...@googlegroups.com
Thanks, I'll give it a try. 'preciate your help.
 
Ian

 
On 20/04/07, Steiner Dominik, (QX59311) <Dominik...@partner.bmw-motorsport.com> wrote:

Hi Ian,

 

I'm sorry to hear that you triped on sth else now. L

Ian Bambury

unread,
Apr 20, 2007, 10:45:28 AM4/20/07
to Google-We...@googlegroups.com
Ha!
 
Just managed to prove that false isn't true...
 

 
Reply all
Reply to author
Forward
0 new messages