users@jersey.java.net

[Jersey] Re: Servlet.Init() For Jersey REST Service

From: juminoz <juminoz_at_hotmail.com>
Date: Fri, 24 Jun 2011 09:15:56 -0700 (PDT)

The problem I have is that I have to call the super constructor as the first
line of the constructor logic. I did try to do the following:

public DSConnectionProvider() {
   //create connection here
   Connection connection = ...

   super(Connection.class, connection);
}

but it's complaining that "super(Connection.class, connection);" has to be
the first line.

I tried rearranging the logic as follow, but got a severe error instead.

public class DSConnectionProvider extends
SingletonTypeInjectableProvider&lt;Context, Connection&gt; {
   static Connection connection;

   public DSConnectionProvider() {
      super(Connection.class, connection);

      //create connection here
      connection = ...
}

Jun 24, 2011 11:07:34 AM 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 method public javax.ws.rs.core.Response
com.ensuant.ece.CollectionServlet.doCreate(java.lang.String,java.lang.String,com.company.core.Connection,java.lang.String)
at parameter at index 2
  SEVERE: Method, public javax.ws.rs.core.Response
com.ensuant.ece.CollectionServlet.doCreate(java.lang.String,java.lang.String,com..company.core.Connection,java.lang.String),
annotated with POST of resource, class com.company.core.CollectionServlet,
is not recognized as valid resource method.

This is the mentioned method

@POST @Path("/create/{username}")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response doCreate(@PathParam("username") String username,
                        @HeaderParam("Content-Type") String contentType,
                        @Context Connection connection,
                        String data) {
}

To me, it seems like it doesn't recognize the "@Context Connection". Did I
do anything wrong?

Thanks,
Jack

--
View this message in context: http://jersey.576304.n2.nabble.com/Servlet-Init-For-Jersey-REST-Service-tp6507144p6512595.html
Sent from the Jersey mailing list archive at Nabble.com.