users@jersey.java.net

[Jersey] Re: Problem with Maven and jersey-test-*

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Tue, 22 Feb 2011 13:44:38 +0100

  On 02/21/2011 09:35 PM, Casper Bang wrote:
>
> it shouldn't be hard - you can give it one more try (try
> build/test that helloworld sample and see how are things done
> there).. or, if you want/may, you can post here some simplified
> project which represents issue you are facing and we should be
> able to find where the problem is..
>
>
> I've played around a bit with the Helloworld sample, changed from JAR
> to WAR but when I when I change jersey-grizzly to jersey-server (I
> want a REST service hosted by an existing container, not an embedded
> Grizzly), the tests fail...
! to be sure I understood you correctly.. You want to run tests against
"external" container, which already have your app deployed and running?
If so, you should use jersey-test-framework-external and invoke your
tests like:

mvn test
-Djersey.test.containerFactory=com.sun.jersey.test.framework.spi.container.external.ExternalTestContainerFactory
-DforkMode=never -Djersey.test.host=<hostname> -Djersey.test.port=<port#>

external container dependency:
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-external</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>



> even if I add jersey-grizzly again under the test scope.
you can use helloworld-webapp sample, if you want to generate war file..

I changed jersey-grizzly dependency to jersey-server and everything
seems to run fine (with 1.6-SNAPSHOT). Additionally, you don't need to
add jersey-grizzly dependency to test scope, this is already introduced
by jersey-test-framework-grizzly (see mvn dependency:tree).

>
> If I add jersey-test-framework-grizzly as test dependency to my own
> project, I keep running into "Could not find artifact
> org.glassfish:javax.servlet:jar:3.0-b66" (Also get it as a warning:
> [WARNING] The POM for org.glassfish:javax.servlet:jar:3.0-b66 is
> missing, no dependency information available).
this is weird.. see
http://download.java.net/maven/glassfish/org/glassfish/javax.servlet/3.0-b66/

are you sure that you are not somehow excluding/ignoring glassfish maven
repo? You might want try to add it to your pom file:

<repository>
<id>glassfish.dev.java.net</id>
<url>http://download.java.net/maven/glassfish</url>
<layout>default</layout>
</repository>

it could help..

btw I'm going to update that dependency to 3.0 final, seems like I
missed it when updating all other references to this one.

> I've extracted the essential parts of my POM and put it here:
> http://xml.pastebin.com/AChR4ukv

You don't need json dependencies, they are already introduced by
jersey-json module. Same applies to javax.servlet (introduced by
jersey-server).

> These errors were introduced recently, we changed this behavior;
> Jersey used to inject nulls, but it lead to even worse errors, so
> currently we emit a error like this, which forces developer to fix
> it early..
>
>
> Fair enough, I've updated the source to reflect those changes and it
> seems to work! :)
excellent :)
>
> well, it is not that hard! Or it definitely shouldn't be. You
> might be encountering some problems when migrating from older
> versions, but we have plenty of updated samples, so you should be
> able to find example for almost everything you want to do. But
> nobody/nothing is perfect, so if you have some concrete ideas for
> improvements, post them here or file new RFE on JIRA.
>
>
> Yeah but problem is, there aren't enough samples to show every
> possible combination - my frustrations likely has more to do with
> Maven than Jersey, as there are a lot of ways to cut a POM cake.
> Thanks for the support, I'm looking forward to diving into actual
> development with Jersey again - I remember falling in love with it
> last time.
that's true, it's nearly impossible to cover all possible combinations
of user webapp/deployment configuration.. but we are trying. If you have
some interesting usecase which wasn't easy to develop/configure, feel
free to share it on our issue tracker or user list and we might add it
to our sample set.
>
> Kind regards,
> Casper

I might be able to help you better if you can share that project and way
how you are executing your tests. You can send it directly to me if you
don't want/can't share it publicly.

Yours sincerely,
Pavel