Blog Archives

Execute JerseyTest case within Eclipse

If you execute a test case within Eclipse, it is possible to fail already on the build of the WebDescriptor. You should add

-Djersey.test.containerFactory=com.sun.jersey.test.framework.spi.container.external.ExternalTestContainerFactory

to your Debug/Run configuration to test against the deployed WAR on the Glassfish server, which runs within Eclipse. Normally the init process of the JerseyTest should find a factory class, if it is within the classpath. The pom.xml contains a dependency to something like

<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-external</artifactId>

which provides the ExternalTestContainerFactory. But Eclipse could not find it and got a NPE on startup of every test case.