java.lang.NoClassDefFoundError: org.junit.runner.Runner
rajivtmathew May 17, 2012 12:04 PMI'm attempting to run a simple test case in arquillian that does a JNDI registration and lookup, internally invoking org.jnp.interfaces.NamingContextFactory from jnpserver.jar
I end up getting the following exception, which I believe, causes the test case to fail.
java.lang.NoClassDefFoundError: org.junit.runner.Runner
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:33)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)
at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethodInternal(JMXTestRunner.java:128)
at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethod(JMXTestRunner.java:107)
at org.jboss.as.arquillian.service.ArquillianService$ExtendedJMXTestRunner.runTestMethod(ArquillianService.java:226)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.invoke(PluggableMBeanServerImpl.java:498)
at org.jboss.as.jmx.PluggableMBeanServerImpl.invoke(PluggableMBeanServerImpl.java:246)
at org.jboss.remotingjmx.protocol.v1.ServerProxy$InvokeHandler.handle(ServerProxy.java:1034)
at org.jboss.remotingjmx.protocol.v1.ServerProxy$MessageReciever$1.run(ServerProxy.java:215)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Here is my test class. I've even tried adding junit.jar and jnpserver.jar into the test archive dependencies, so they could be resolved. But none of this makes a difference.
@RunWith(Arquillian.class)
public class TestJNDILookupBinding {
private String jndiName = "java:app/TestManager";
@Inject
InitialContext initialContext;
@Inject
InitialContextFactory factory;
@Deployment
public static WebArchive createTestArchive() {
return ShrinkWrap.create(WebArchive.class, "archive.war")
.addClass(InitialContext.class)
.addClass(InitialContextFactory.class)
.addAsLibraries(
DependencyResolvers.use(MavenDependencyResolver.class)
.artifact("junit:junit:4.10").resolveAs(GenericArchive.class))
.addAsLibraries(
DependencyResolvers.use(MavenDependencyResolver.class)
.artifact("jboss:jnpserver:4.2.2.GA").resolveAs(GenericArchive.class))
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
}
@Test
public void testJNDILookup() throws NamingException {
InitialContext initialContext = InitialContextFactory.getInitialContext();
initialContext.bind(jndiName, objM);
Assert.assertEquals(initialContext.lookup(jndiName), objM);
}