users@jersey.java.net

ContainerException: Exception injecting parameters to Web resource method via NPE

From: Davis Ford <davisford_at_gmail.com>
Date: Wed, 19 Nov 2008 15:33:42 -0500

Hi,

I've changed my mvn project around a bit now to automatically launch
Jetty for pre-integration-phase and shut it down for
post-integration-phase. With my current configuration "mvn jetty:run,
mvn jetty:run-war", etc. all work fine.

However, I want to put this into a CI system, and have maven
automatically start Jetty when I run the integration-test phase. I do
this via the configuration below, but when I run, and Jetty kicks off,
I see this when my Integration Test runs:

2008-11-19 15:30:28.512::WARN: /efax/incoming-fax
com.sun.jersey.api.container.ContainerException: Exception injecting
parameters to Web resource method
        at com.sun.jersey.impl.model.method.dispatch.FormDispatchProvider$FormParamInInvoker.getParams(FormDispatchProvider.java:99)

etc..further down ->

Caused by: com.sun.jersey.api.container.ContainerException:
java.lang.NullPointerException
        at com.sun.jersey.impl.model.method.dispatch.MultipartFormDispatchProvider$MultipartFormParamInjectable.getValue(MultipartFormDispatchProvider.java:145)
        at com.sun.jersey.impl.model.method.dispatch.FormDispatchProvider$FormParamInInvoker.getParams(FormDispatchProvider.java:93)
        ... 27 more
Caused by: java.lang.NullPointerException
        at com.sun.jersey.impl.model.method.dispatch.MultipartFormDispatchProvider$MultipartFormParamInjectable.getAsForm(MultipartFormDispatchProvider.java:152)
        at com.sun.jersey.impl.model.method.dispatch.MultipartFormDispatchProvider$MultipartFormParamInjectable.getValue(MultipartFormDispatchProvider.java:140)

If I do this by manually starting Jetty via (mvn jetty:run), and then
run this same integration test from inside Eclipse, it passes no
problem.

This is how I set up the pom.xml :

Surefire plugin will only run test named **IntegrationTest* under the
integration-test phase.

<plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
                <excludes>
                        <exclude>**/*IntegrationTest*.java</exclude>
                </excludes>
        </configuration>
        <executions>
                <execution>
                        <id>integration-test</id>
                        <goals>
                                <goal>test</goal>
                        </goals>
                        <phase>integration-test</phase>
                        <configuration>
                                <excludes>
                                        <exclude>none</exclude>
                                </excludes>
                                <includes>
                                        <include>**/*IntegrationTest*.java</include>
                                </includes>
                        </configuration>
                </execution>
        </executions>
</plugin>

And then I configured Jetty like this:

<plugin>
        <!-- JETTY 6 PLUGIN -->
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.1.14</version>
        <configuration>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <contextPath>/efax</contextPath>
                <connectors>
                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                                <port>4000</port>
                                <maxIdleTime>60000</maxIdleTime>
                        </connector>
                </connectors>
                <jetty-config>jetty.xml</jetty-config>
                <webApp>${basedir}/target/efax</webApp>
        </configuration>
        <executions>
                <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                                <goal>run-war</goal>
                        </goals>
                        <configuration>
                                <scanIntervalSeconds>0</scanIntervalSeconds>
                                <daemon>true</daemon>
                        </configuration>
                </execution>
                <execution>
                        <id>stop-jetty</id>
                        <phase>post-integration-test</phase>
                        <goals>
                                <goal>stop</goal>
                        </goals>
                </execution>
        </executions>
</plugin>

-- 
Zeno Consulting, Inc.
http://www.zenoconsulting.biz
248.894.4922 phone
313.884.2977 fax