Quantcast
Channel: Ignite Realtime : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 10742

Integrating Jersey (JAX-RS) with Openfire

$
0
0

Hi,

 

I want to create a plugin that allows access to some features of openfire by a RESTful webservice. I therefore tried to integrate jersey to openfire but did not suceed yet.

 

The PluginServlet allows the use of custom HttpServlets so I thought this is the right point to start from and as the jersey ServletContainer extends from the java HttpServlet but I have some issues with the url mapping.

 

This is what I have accomplished so far:

 

my web-custom.xml:

 

<?xml version='1.0' encoding='ISO-8859-1'?>

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

   

<servlet>

    <servlet-name>RESTServiceServlet</servlet-name>       

    <servlet-class>com.mypackage.RESTServiceServlet</servlet-class>

 

    <init-param>

        <param-name>jersey.config.server.provider.packages</param-name>

        <param-value>com.mypackage</param-value>           

    </init-param>       

    <load-on-startup>1</load-on-startup>

 

</servlet>

 

<!-- Servlet mappings -->

<servlet-mapping>

    <servlet-name>RESTServiceServlet</servlet-name>

    <url-pattern>/restservice/*</url-pattern>

</servlet-mapping>

 

</web-app>

 

 

for debugging purposes I extended the jersey ServletContainer to the RESTServiceServlet mentioned above:

 

@Override

    public Value<Integer> service(URI baseUri, URI requestUri, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

 

   System.out.println("baseUri: " + baseUri);
   System.out.println("requestUri: " + requestUri);
   System.out.println("contextPath: " + request.getContextPath());
   System.out.println("pathInfo: " + request.getPathInfo());
   System.out.println("translated: " + request.getPathTranslated());
   System.out.println("requestURI: " + request.getRequestURI());
   System.out.println("servletPath:" + request.getServletPath());
   System.out.println("");

 

   return super.service(baseUri, requestUri, request, response);

    }

 

I then added a simple pojo hello world class with

 

@Path("hello")

 

and then tried to open http://localhost:9090/plugins/restservice/restservice/hello

but I only get a 404 error. The debug output looks like this:

 

baseUri: http://localhost:9090/plugins/

requestUri: http://localhost:9090/plugins/restservice/restservice/hello

contextPath:

pathInfo: /restservice/restservice/hello

requestURI: /plugins/restservice/restservice/hello

servletPath:/plugins

 

 

I think the problem is the mapping but I dont know how to solve it, maybe the @Path is wrong or the mapping in the web-custom.xml?

Any help is appreciated, I've been trying for hours


Viewing all articles
Browse latest Browse all 10742

Trending Articles