Eclipse: java.lang.NoClassDefFoundError: org/objectweb/asm/Opcodes

3,305 views
Skip to first unread message

Rakesh Patel

unread,
Apr 17, 2013, 12:44:29 PM4/17/13
to robol...@googlegroups.com
I am running roboelectric test in eclipse. I updated roboelectic jar to use alpha-2 from 1.2 since I was facing issues testing fragments. 
I came across this exception while running with alpha-2:

java.lang.NoClassDefFoundError: org/objectweb/asm/Opcodes
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.robolectric.RobolectricTestRunner.<init>(RobolectricTestRunner.java:67)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Opcodes
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 31 more


Any idea what can be wrong here?

Thanks,
Rakesh

Pete

unread,
Apr 23, 2013, 7:04:14 AM4/23/13
to robol...@googlegroups.com
I have encountered the exact same problem!

Pete

unread,
Apr 23, 2013, 7:24:04 AM4/23/13
to robol...@googlegroups.com
The problem is one of dependencies.

I found that if I tracked-down and added a jar with the correct classes in, and then another... and then another... I still end-up with unresolved dependencies.

It'd be great if the instructions could be updated for those of us who use Eclipse, and don't use Maven...

Pete

unread,
Apr 23, 2013, 7:41:47 AM4/23/13
to robol...@googlegroups.com
All now sorted.

I found that I had go here to download the "all with dependencies" jar (click on the Artifact tab):
https://oss.sonatype.org/index.html#nexus-search;quick~robolectric
... the specific file was this:
/org/robolectric/robolectric/2.0-alpha-3-SNAPSHOT/robolectric-2.0-alpha-3-20130422.230702-53-jar-with-dependencies.jar


... and then get this (which was missing from the above file ...)
http://repo1.maven.org/maven2/org/easytesting/fest-util/1.1.6/fest-util-1.1.6.jar

... My basic test then worked! :)

Reply all
Reply to author
Forward
0 new messages