users@jersey.java.net

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

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Mon, 21 Feb 2011 17:38:49 +0100

On 02/21/2011 03:41 PM, Casper Bang wrote:
> Thanks Pavel, but I really can't get it to work no matter what I try.
> I will disable the testing and come back to it sometime in the future
> (yeah right).
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..

>
> However now everything compiles, I have got another problem when
> running it as war in Tomcat:
>
> INFO: Provider classes found:
> class com.brunata.webmon.ws.resources.ParserExceptionMapper
> class com.brunata.webmon.ws.resources.InvalidCredentialsExceptionMapper
> Feb 21, 2011 3:29:52 PM
> com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
> INFO: Initiating Jersey application, version 'Jersey: 1.5 01/14/2011
> 12:36 PM'
> Feb 21, 2011 3:29:52 PM com.sun.jersey.spi.inject.Errors
> processErrorMessages
> SEVERE: The following errors and warnings have been detected with
> resource and/or provider classes:
> SEVERE: Missing dependency for field: private
> javax.ws.rs.core.Response
> com.brunata.webmon.ws.resources.RootResource.response
> SEVERE: Missing dependency for constructor public
> com.brunata.webmon.ws.resources.ChartResource(javax.servlet.ServletContext)
> at parameter index 0
> SEVERE: Missing dependency for field: private
> com.sun.jersey.api.core.HttpRequestContext
> com.brunata.webmon.ws.resources.LoginResource.rc
> SEVERE: Missing dependency for field: private
> com.sun.jersey.api.core.HttpRequestContext
> com.brunata.webmon.ws.resources.TestResource.rc
>
> The WAR file has jersey-core.jar, jersey-server.jar so I am really not
> sure how I should interpret the "Missing dependecy..." messages?

That usually means you are trying to inject something which Jersey don't
know/have in that moment. For example the first error complains about
injecting Response - you can't do that, Jersey doesn't have the Response
instance when creating resource class.. and others.. are similar, Jersey
don't know anything about request when creating resource instance -
remove HttpRequestContext from constructor and inject it into a private
field for example..

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..

>
> /Casper
>
> PS: I love developing with Jersey, but it is a bit of a configuration
> nightmare unless you work with it all the time it seems.

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.

Hope your experience with Jersey improves!

Regards,
Pavel

>
>
>
> On Mon, Feb 21, 2011 at 12:01 PM, Pavel Bucek <pavel.bucek_at_oracle.com
> <mailto:pavel.bucek_at_oracle.com>> wrote:
>
> Hello Casper,
>
> you have to remove dependency on
> com.sun.jersey.jersey-test-framework, its "nothing" now; see
> helloworld sample for inspiration, basically you should have
> something like:
>
> <dependency>
> <groupId>com.sun.jersey.jersey-test-framework</groupId>
> <artifactId>jersey-test-framework-grizzly</artifactId>
> <version>${project.version}</version>
> <scope>test</scope>
> </dependency>
>
> helloworld sample:
> http://download.java.net/maven/2/com/sun/jersey/samples/helloworld/1.6-SNAPSHOT/helloworld-1.6-SNAPSHOT-project.zip
>
> Regards,
> Pavel
>
>
>
> On 02/21/2011 11:54 AM, Casper Bang wrote:
>> Hello list,
>>
>> After laying dormant for about a year, I got back to my Maven
>> project using Jersey. Rolling forward to most recent stable
>> dependencies (i.e. Jersey 1.5) I've run into some trouble with
>> the unit testing parts.
>>
>> I used to only rely on jersey-test-framework, but now the wiki
>> [http://jersey.java.net/nonav/documentation/latest/user-guide.html#d4e1298]
>> says it requires jersey-test-framework-grizzly. However, if I add
>> this dependency, my project refuses to compile due to transient
>> dependency of org.glassfish:javax.sevlet.jar:3.0-b66:
>>
>>
>> Missing:
>>
>> ----------
>>
>> 1) org.glassfish:javax.servlet:jar:3.0-b66
>>
>>
>>
>> Try downloading the file manually from the project website.
>>
>>
>>
>> Then, install it using the command:
>>
>> mvn install:install-file -DgroupId=org.glassfish
>> -DartifactId=javax.servlet -Dversion=3.0-b66 -Dpackaging=jar
>> -Dfile=/path/to/file
>>
>>
>>
>> Alternatively, if you host your own repository you can deploy the
>> file
>> there:
>>
>> mvn deploy:deploy-file -DgroupId=org.glassfish
>> -DartifactId=javax.servlet -Dversion=3.0-b66 -Dpackaging=jar
>> -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
>>
>>
>>
>> Path to dependency:
>>
>> 1) com.brunata:ws-webmon:war:1.3-SNAPSHOT
>>
>> 2)
>> com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly:jar:1.5
>>
>> 3)
>> com.sun.jersey.jersey-test-framework:jersey-test-framework-core:jar:1.5
>>
>> 4) org.glassfish:javax.servlet:jar:3.0-b66
>>
>>
>>
>>
>> I find it odd that 1) there should be a dependency of a
>> specific (glassfish) servlet implementation and 2) that the
>> dependency can't be found yet observed in the java.net
>> <http://java.net>
>> repo[http://download.java.net/maven/glassfish/org/glassfish/javax.servlet/3.0-b66/javax.servlet-3.0-b66.pom].
>>
>>
>>
>>
>> I'm also getting an error for jersey-test-framework:
>>
>>
>>
>> 2) com.sun.jersey:jersey-test-framework:jar:1.5
>>
>> Try downloading the file manually from the project website.
>>
>> Then, install it using the command:
>> mvn install:install-file -DgroupId=com.sun.jersey
>> -DartifactId=jersey-test-framework -Dversion=1.5 -Dpackaging=jar
>> -Dfile=/path/to/file
>>
>> Alternatively, if you host your own repository you can deploy
>> the file there:
>> mvn deploy:deploy-file -DgroupId=com.sun.jersey
>> -DartifactId=jersey-test-framework -Dversion=1.5 -Dpackaging=jar
>> -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
>>
>> Path to dependency:
>> 1) com.brunata:ws-webmon:war:1.3-SNAPSHOT
>> 2) com.sun.jersey:jersey-test-framework:jar:1.5
>>
>> Since this dependency is mentioned by a wiki referenced blog
>> entry
>> [http://blogs.sun.com/naresh/entry/jersey_test_framework_makes_it] and
>> indeed seems visible in the java.net <http://java.net> repo
>> [http://download.java.net/maven/2/com/sun/jersey/jersey-test-framework/1.5/]
>> it seems a bit odd.
>>
>> Perhaps I am missing a repository:
>>
>> 2 required artifacts are missing.
>>
>> for artifact:
>> com.brunata:ws-webmon:war:1.3-SNAPSHOT
>>
>> from the specified remote repositories:
>> central (http://repo1.maven.org/maven2),
>> releases (http://maven.brunata.dk/releases),
>> terracotta-repository
>> (http://www.terracotta.org/download/reflector/maven2),
>> internal (http://maven.brunata.dk/internal),
>> maven2-repository.dev.java.net
>> <http://maven2-repository.dev.java.net>
>> (http://download.java.net/maven/2/),
>> snapshots (http://maven.brunata.dk/snapshots),
>> dist.wso2.org <http://dist.wso2.org> (http://dist.wso2.org/maven2/),
>> maven-repository.dev.java.net
>> <http://maven-repository.dev.java.net>
>> (http://download.java.net/maven/1)
>>
>> ...or does something else jump in the eye? Perhaps there's an
>> up-to-date sample using jersey-test-* which can work as a
>> template for porting my stuff over. Thanks in advance for
>> pointers. :)
>>
>> /Casper
>
>