web-applicationsservletsjerseyjax-rsjsr311

JAX-RS External Service Library


I have a group of cut and paste JAX-RS 1.1.1 annotated classes that I share between 4 services. These are management services that provide telemetry from process like hibernate and a common version info resource. In my web.xml I supply the fully qualifed name for the external packages, but they are not getting picked up. Has anyone created a library of JAX-RS services and included them in disparate services?

My web.xml

<init-param>
  <param-name>com.sun.jersey.config.property.packages</param-name>
  <param-value>com.mycompany.webserivce.rest.resource1;
               com.mycompany.webservice.rest.resource2;
               com.mycompany.webservice.rest.providers;
               com.mycompany.common.rest.stats;
  </param-value>
</init-param>

At runtime the log shows

INFO: Scanning for root resource and provider classes in the packages:
  com.mycompany.webserivce.rest.resource1;
  com.mycompany.webservice.rest.resource2;
  com.mycompany.webservice.rest.providers;
  com.mycompany.common.rest.stats;
INFO: Root resource classes found:
  class com.mycompany.webserivce.rest.resource1.Resource1Resource;
  class com.mycompany.webserivce.rest.resource2.Resource2Resource;
INFO: Provider classes found:     
  class com.mycompany.webservice.rest.providers.Resource1XMLWriter;
  class com.mycompany.webservice.rest.providers.Resource2XMLWriter;
INFO: Initting jersey....

As you can see, the root resources from com.mycompany.common.rest.stats are not found.


Solution

  • The problem was I added the common lib to the wrong POM. Once I added it to the correct POM it all worked.