users@jersey.java.net

[Jersey] How to deal with WARNING: No injection source found for a parameter of type ...?

From: Thomas Manson <dev.mansonthomas_at_gmail.com>
Date: Thu, 30 Jul 2015 09:53:08 +0200

Hi all,

I'm new to Jersey and I'm converting an existing project (for the French
Red Cross) from DWR (www.directwebremoting.org) to Jersey.

My project code is available here :
https://github.com/dev-mansonthomas/crf-rdp

I've some exposed methods that takes a Java Object as parameter, and on
startup I get warnings :

2015-07-30 09:27:38,459 - INFO - RMI TCP Connection(2)-127.0.0.1
(FrameworkServlet.java:503) - FrameworkServlet 'crf-rdp-spring-mvc':
initialization completed in 173 ms
juil. 30, 2015 9:27:39 AM org.glassfish.jersey.internal.Errors logErrors
SEVERE: Following issues have been detected:
WARNING: No injection source found for a parameter of type public void
fr.croixrouge.rdp.services.restServices.homepage.EquipiersGestion.createEquipier(fr.croixrouge.rdp.model.monitor.Equipier)
throws java.lang.Exception at index 0.
WARNING: No injection source found for a parameter of type public void
fr.croixrouge.rdp.services.restServices.homepage.EquipiersGestion.modifyEquipier(fr.croixrouge.rdp.model.monitor.Equipier)
throws java.lang.Exception at index 0.

2015-07-30 09:27:39,766 - WARN - RMI TCP Connection(2)-127.0.0.1
(JawrRequestHandler.java:376) - Jawr initialized in DEVELOPMENT MODE. Do
NOT use this mode in production or integration servers.

Do you have any hint to share with me ?


The concerned code :

@Component
@Path("/equpier")
@Produces(MediaType.APPLICATION_JSON)
@Api(value="EquipierEditor", description="Allow to do CRUD+Search
operation on Equipier")

public class EquipiersGestion
{

....

@POST
@Consumes("application/json")
@ApiOperation(value="Create a new Equipier")
@Path("/create")
public void createEquipier(@ApiParam(value="equipier"
,required=true) @QueryParam ("equipier")Equipier equipier) throws
Exception
{

...

My Jersey initialization is done this way :

web.xml
<servlet>
   <servlet-name>Jersey REST Service</servlet-name>
   <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
   <!-- Register resources and providers under
com.vogella.jersey.first package. -->
   <init-param>
      <param-name>javax.ws.rs.Application</param-name>
      <param-value>fr.croixrouge.rdp.services.restServices.JerseyRegisterResource</param-value>
   </init-param>
   <load-on-startup>1</load-on-startup>
</servlet>


   <servlet>
       <servlet-name>Jersey2Config</servlet-name>
       <servlet-class>com.wordnik.swagger.jersey.config.JerseyJaxrsConfig</servlet-class>
       <init-param>
           <param-name>api.version</param-name>
           <param-value>1.1.1</param-value>
       </init-param>
       <init-param>
           <param-name>swagger.api.basepath</param-name>
           <param-value>http://localhost:8080/crf-rdp/private/rest</param-value>
       </init-param>
       <load-on-startup>2</load-on-startup>
   </servlet>


<servlet-mapping>
   <servlet-name>Jersey REST Service</servlet-name>
   <url-pattern>/private/rest/*</url-pattern>
</servlet-mapping>


fr.croixrouge.rdp.services.restServices.JerseyRegisterResource

public class JerseyRegisterResource extends ResourceConfig
{
  public JerseyRegisterResource()
  {
    //CRF-RDP app
    register(LieuEditor.class);
    register(EquipiersGestion.class);
    register(Homepage.class);

    register(CreditsAndChangeLogDwrService.class);
    register(InterventionListService.class);
    register(JacksonFeature.class);
    register(MultiPartFeature.class);

    packages(true, "fr.croixrouge.rdp.model.monitor");

    //swagger
    register(com.wordnik.swagger.jersey.listing.ApiListingResourceJSON.class);
    register(com.wordnik.swagger.jersey.listing.JerseyApiDeclarationProvider.class);
    register(com.wordnik.swagger.jersey.listing.JerseyResourceListingProvider.class);

  }

my pom.xml


<properties>
    <org.springframework.version>4.1.6.RELEASE</org.springframework.version>
    <org.apache.httpcomponents.version>4.1.1</org.apache.httpcomponents.version>
    <com.sun.jersey>2.19</com.sun.jersey>
    <com.wordnik.swagger>1.3.12</com.wordnik.swagger>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<!-- Jersey/REST -->
<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-moxy</artifactId>
</dependency>

<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
</dependency>

<dependency>
    <groupId>org.glassfish.jersey.ext</groupId>
    <artifactId>jersey-spring3</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.glassfish.hk2</groupId>
            <artifactId>hk2</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- jersey end -->

<!-- swagger -->
<dependency>
    <groupId>com.wordnik</groupId>
    <artifactId>swagger-jersey2-jaxrs_2.11</artifactId>
    <version>${com.wordnik.swagger}</version>
</dependency>

<dependency>
    <groupId>com.wordnik</groupId>
    <artifactId>swagger-core_2.11</artifactId>
    <version>${com.wordnik.swagger}</version>
</dependency>
<dependency>
    <groupId>com.wordnik</groupId>
    <artifactId>swagger-jaxrs_2.11</artifactId>
    <version>${com.wordnik.swagger}</version>
</dependency>
<!-- swagger end-->



Thanks for your help !

Thomas.