0

I am running JBOSS 6.4 EAP in eclipse oxygen.

I have a simple and working webservice that just returns is alive.

When I configure the url-pattern as " /* " it is executed as expected. When I put a more substantial pattern "/rws/*" in the url-pattern I get 404

My URL is localhost:8080/mesh/rws/menu/isAlive

failing web.xml There is no corresponding servlet block for this servlet

<servlet-mapping>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
    <url-pattern>/rws/*</url-pattern>
</servlet-mapping>

Servlet Class

@Path("/rws/menu")
public class MenuService
{
    @GET
    @Path("/isAlive")
    public Response isAlive()
    {
        return Response.ok("I am alive").build();
    }
}

Error from Server

JBWEB000065: HTTP Status 404 - RESTEASY001185: Could not find resource for relative : /menu/isAlive of full path: http://localhost:8080/mesh/rws/menu/isAlive

Context param I have tried adding the context param to web.xml as suggested in various places on line, but it seems already set and I am not sure how to over ride.

<context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/rws</param-value>
</context-param >

yields error:

ERROR [org.apache.catalina.core] (ServerService Thread Pool -- 64) JBWEB001097: Error starting context /mesh: java.lang.IllegalArgumentException: JBWEB000280: Duplicate context initialization parameter resteasy.servlet.mapping.prefix

Aaron
  • 874
  • 3
  • 17
  • 34
  • When you have `/rws/*` in the url-pattern, you are not supposed to put `/rws` in the `@Path` also. If you do this, then the url would be `/rws/rws`. The url-pattern is the prefix for the entire application – Paul Samsotha May 22 '18 at 05:11
  • @PaulSamsotha Your suggested solution also works. If you put in an answer I can accept it. – Aaron May 22 '18 at 18:53

2 Answers2

0

Here is what I ended up with. I can't give a full explanation of why this works, but here is my specuylation. This defines a new servlet using the core.Application class, so the default implementation used in teh question is ignored. Thus there is no need for setting the context parameter as I tried to do in the original question.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">

    <servlet>
        <servlet-name>EbigExtWS</servlet-name>
        <servlet-class>javax.ws.rs.core.Application</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>EbigExtWS</servlet-name>
        <url-pattern>/rws/*</url-pattern>
    </servlet-mapping>

</web-app>
Aaron
  • 874
  • 3
  • 17
  • 34
0

When you have /rws/* in the url-pattern, you're not supposed to put /rws in the @Path also. If you do this, then the url would be /rws/rws. The url-pattern is the prefix for the entire application. So just remove the /rws from the @Path.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720