Hello community,
I have a plugin with functionality that I wish to expose through a REST api. I have chosen to try Jersey which I have successfully used in other Servlet containers such as Jetty. I am adding the necessary configuracion for Jersey in the web-custom.xml file of my plugin (which normally goes in the web.xml file of a webapp). Here it is as follows:
<servlet>
<servlet-name>Jersey REST Service</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>myproject.openfire.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
The problem is that openfire doesn't seem to find/load the Jersey classes, and thus I get the following error:
INFO: Scanning for root resource and provider classes in the Web app resource paths:
/WEB-INF/lib
/WEB-INF/classes
2010.06.09 16:44:58 [org.jivesoftware.openfire.container.PluginServlet.registerServlets(PluginServl et.java:168)
]
com.sun.jersey.spi.service.ServiceConfigurationError: com.sun.jersey.spi.container.WebApplicationProvider: The class com.sun.jersey.server.impl.container.WebApplicationProviderImpl implementing the provider interface com.sun.jersey.spi.container.WebApplicationProvider is not found. The provider implementation is ignored....
I can solve this by placing the Jersey jar files in the openfire/lib folder (instead of in myplugin/lib), but that's really messy. Moreover, even after that it still cannot find my REST resources classes, and I get this error:
"SEVERE: The ResourceConfig instance does not contain any root resource classes."
2010.06.09 16:48:03 [java.util.logging.Logger.log(Logger.java:458)
] The ResourceConfig instance does not contain any root resource classes.
2010.06.09 16:48:03 [org.jivesoftware.openfire.container.PluginServlet.registerServlets(PluginServl et.java:168)
]
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
at com.sun.jersey.server.impl.application.WebApplicationImpl.processRootResources( WebApplicationImpl.java:1070)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicati onImpl.java:918)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicati onImpl.java:589)
at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer .java:429)
The package I specified in the param-value field in the web-custom.xml is the correct one, and as I said, the above configuration works just fine on Jetty or Tomcat.
Any help would be highly, highly appreciated!
Many thanks,
Diana.