NPE initializing JerseyTest

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

NPE initializing JerseyTest

Richard Sand
Hello Jersey Community -

I'm using the following code to initialize my JerseyTest. The test works with Grizzly as the test container, but fails with an NPE inside the JerseyTest constructors when using InMemory or Jetty.

Is this a bug or am I doing something wrong? Using Jersey 2.22.2. My JerseyTest initialization code is as follows:

public class AdminServiceJerseyTests extends JerseyTest {
    @Override
    protected DeploymentContext configureDeployment() {
        enable(TestProperties.DUMP_ENTITY);
        return ServletDeploymentContext
                .forServlet(new ServletContainer(new ResourceConfig(AdminService.class)))
                .contextParam("ldaphost", "localhost")
                .contextParam("ldapport", "1389")
                .build();
    }


    @Override
    protected TestContainerFactory getTestContainerFactory() {
        //return new InMemoryTestContainerFactory();
        //return new GrizzlyWebTestContainerFactory();
        return new JettyTestContainerFactory();
    }

This is the stacktrace:

java.lang.NullPointerException
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:331)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:311)
    at org.glassfish.jersey.jetty.JettyHttpContainer.<init>(JettyHttpContainer.java:474)
    at org.glassfish.jersey.jetty.JettyHttpContainerProvider.createContainer(JettyHttpContainerProvider.java:60)
    at org.glassfish.jersey.server.ContainerFactory.createContainer(ContainerFactory.java:81)
    at org.glassfish.jersey.jetty.JettyHttpContainerFactory.createServer(JettyHttpContainerFactory.java:161)
    at org.glassfish.jersey.test.jetty.JettyTestContainerFactory$JettyTestContainer.<init>(JettyTestContainerFactory.java:91)
    at org.glassfish.jersey.test.jetty.JettyTestContainerFactory$JettyTestContainer.<init>(JettyTestContainerFactory.java:68)
    at org.glassfish.jersey.test.jetty.JettyTestContainerFactory.create(JettyTestContainerFactory.java:149)
    at org.glassfish.jersey.test.JerseyTest.createTestContainer(JerseyTest.java:277)
    at org.glassfish.jersey.test.JerseyTest.setUp(JerseyTest.java:609)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  ....

Thanks for any help!

-Richard
Loading...