users@jersey.java.net

[Jersey] Missing dependency error in jersey 1.12 grizzly server

From: Guilhem <guilhem.legal_at_geomatys.fr>
Date: Tue, 20 Mar 2012 10:23:38 +0100

hi,

I'm using jersey for Rest WS both with tomcat 7 and grizzly httpserver.

I try to move from 1.11 to 1.12, everything works for tomcat but i
always get an error at grizzly startup for injected fields.

I download the helloworld samples from :

https://maven.java.net/content/repositories/releases/com/sun/jersey/samples/helloworld/1.12/

Add the maven dependency to : jersey-grizzly2-servlet

And add an injected field to the HelloWorld resource :

@Context
private ServletContext context;


I get this error when i'll try to run :

INFO: Initiating Jersey application, version 'Jersey: 1.12 02/15/2012
04:51 PM'
20 mars 2012 10:09:57 com.sun.jersey.spi.inject.Errors processErrorMessages
GRAVE: The following errors and warnings have been detected with
resource and/or provider classes:
   SEVERE: Missing dependency for field: private
javax.servlet.ServletContext
com.sun.jersey.samples.helloworld.resources.HelloWorldResource.context
Exception in thread "main"
com.sun.jersey.spi.inject.Errors$ErrorMessagesException
     at
com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
     at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
     at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
     at
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:773)
     at
com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:172)
     at
com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:134)
     at
com.sun.jersey.api.container.grizzly2.GrizzlyServerFactory.createHttpServer(GrizzlyServerFactory.java:242)
     at com.sun.jersey.samples.helloworld.Main.startServer(Main.java:75)
     at com.sun.jersey.samples.helloworld.Main.main(Main.java:81)


I see in the dependency graph that the jar org.glassfish.javax.servlet
is included so the class "javax.servlet.ServletContext" shoule be found.


Any idea to fix this problem ?


Guilhem Legal