1

To replace my existing Struts application with JAX-RS, I need to support the servlet extension mapping (*.do). So, I registered Apache JAX-RS servlet as follow:

    <display-name>jaxrs_wink</display-name>
    <servlet>
            <description>
            JAX-RS Tools Generated - Do not modify</description>
            <servlet-name>JAX-RS Servlet</servlet-name>
            <servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
            <init-param>
                    <param-name>javax.ws.rs.Application</param-name>
                    <param-value>tests.SampleApplication</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
            <enabled>true</enabled>
            <async-supported>false</async-supported>
    </servlet>
    <servlet-mapping>
            <servlet-name>JAX-RS Servlet</servlet-name>
            <url-pattern>*.do</url-pattern>
    </servlet-mapping>

Note that the element specifies an extension mapping. The problem is that the extension mapping is not working with Apache Wink 1.4. However, it works with Jersey.

To reproduce this problem, create the following JAX-RS resource class and application. Try to visit: http:////hi.do

I am getting WebApplicationException (405) from Wink. But, with Jersey, it worked okay. I want to know whether the extension mapping should work according to JAX-RS v1.1. I searched the spec, but I could not find any specific comment on servlet mapping.

package tests;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("/")
public class SampleResource {

    @GET
    @Path("hi.do")
    public String sayHi() {
            return "Hello World!";
    }

}

package tests;

import java.util.HashSet;
import java.util.Set;

import javax.ws.rs.core.Application;

public class SampleApplication extends Application {

    @Override
    public Set<Class<?>> getClasses() {
            Set<Class<?>> classes = new HashSet<Class<?>>();
            classes.add(SampleResource.class);
            return classes;
    }

}
Chris Harris
  • 1,329
  • 4
  • 17
  • 28

0 Answers0