Search code examples
javawebjbossjax-rsurl-mapping

Is my issue a result of incorrect url-mappings?


I have a JBOSS ASS7 server hosting an application written in java. this application has both JAX-RS functions (for responding to some API calls) as well as some servlets.

I have a web.xml which includes the following two mappings:

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

 <servlet>
        <servlet-name>adminServlet</servlet-name>
        <jsp-file>/admin.jsp</jsp-file>
 </servlet>
 <servlet-mapping>

<servlet-name>adminServlet</servlet-name>
        <url-pattern>/admin/</url-pattern>
</servlet-mapping>

In one of my .java files I have:

    @Path("/api/check")
public class ContentCheck {
    private static final Logger Log = LoggerFactory.getLogger(ContentCheck.class);
...etc

And it might also help to know that my jboss-web.xml has:

    <jboss-web>
  <context-root>contentcheck</context-root>
</jboss-web>

Now the problem is that if I got to:

my.IP.Address/contentcheck/admin.jsp 

I get an http 200 (and my page)

but if I go to

my.IP.Address/contentcheck/api/check

I get an http 404.

The only clue I can find is in the error description which talks about problems finding a relative path: type Status report

message: Could not find resource for relative : /check of full path: my.IP.Address/contentcheck/api/check?ID=1

description: The requested resource (Could not find resource for relative : /check of full path: /contentcheck/api/check) is not available.

I think if I just try to hit a nonsense URL on a JBOSS server I get:

message: /contentcheck/wdwqd

description: The requested resource (/contentcheck/wdwqd) is not available.

Many thanks for any help you can provide


Solution

  • I think you can fix this by changing @Path("/api/check") to @Path("/check"). Alternatively, change your path in your web.xml from '/api/' to '/', but is suspect the former is a more suitable solution.

    Currently I believe JAXRS would work if you visited /api/api/check