I need to have multiple prefixes in my RestEasy project. For the same, I have defined multiple servlets as below in web.xml
.
<servlet>
<servlet-name>resteasy-servlet1</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
<init-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest1</param-value>
</init-param>
<init-param>
<param-name>resteasy.resources</param-name>
<param-value>com.test.rs.TokenGenerator</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>resteasy-servlet2</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
<init-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest2</param-value>
</init-param>
<init-param>
<param-name>resteasy.resources</param-name>
<param-value>com.test.rs.ResourceProvider</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>resteasy-servlet1</servlet-name>
<url-pattern>/rest1/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>resteasy-servlet2</servlet-name>
<url-pattern>/rest2/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>AuthFilter</filter-name>
<filter-class>com.test.rs.filter.AuthFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthFilter</filter-name>
<url-pattern>/rest2/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
The same approach is defined in this stackoverflow post, but
I haven't got it working in my project yet. I always get back 404 Not Found
error when trying to access the URLs below. Can anyone highlight what I am missing in the configuration?
The web context root of the project deployed is rstest
My class has the @Path
annotation defined as below
@Path("/token")
public class TokenGenerator {