0

I've created a .jar with some Jersey web services in it, and I want to import that .jar in other projects. Those web services work like a handler/proxy for local code to link with a remote service provider.

So, I import the .jar document in a project and configure web.xml like this:

<servlet>
  <servlet-name>Services</servlet-name>
  <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
  <init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>com.package.for.services.in.current.project, com.package.for.services.in.jar</param-value>
  </init-param>
</servlet>
<servlet-mapping>
  <servlet-name>Services</servlet-name>
  <url-pattern>/s/*</url-pattern>
</servlet-mapping>

But when I run the project, the web services specified in com.package.for.services.in.jar aren't found.

The .jar document is in build path. What am I doing wrong? Isn't possible to run web services from an external library?

Thanks in advance.

vermicida
  • 303
  • 1
  • 4
  • 11

1 Answers1

0

I found the answer from this post: Jersey REST The ResourceConfig instance does not contain any root resource classes

The PackagesResourceConfig class depends on having a directory with the name of the package in order to find the classes within it. I went back to Eclipse, and found an option at the bottom of the "Export ... > Jar" dialog for "Add directory entries." I turned that on, exported the jar again, and then the scanning found my resource classes. You'll need to find some comparable option in your build environment.

Community
  • 1
  • 1
Alao
  • 390
  • 5
  • 11