0

I'm trying to map a Jetty Servlet with a POST request having a variable URI.
I'm specifying a URI with a prefix and a wildcard. The web.xml looks like this

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

         <display-name>my service
             </display-name>
             <welcome-file-list>
                 <welcome-file>myApplication/index.html</welcome-file>
                 <welcome-file>index.html</welcome-file>
             </welcome-file-list>

             <context-param>
                 <param-name>log4jConfigLocation</param-name>
                 <param-value>/WEB-INF/classes/log4j.properties</param-value>
             </context-param>

             <servlet>
                 <servlet-name>my-service</servlet-name>
                 <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
                 <init-param>
                     <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
                     <param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
                 </init-param>
                 <init-param>
                     <param-name>com.sun.jersey.config.property.packages</param-name>
                     <param-value>org.my.service</param-value>
                 </init-param>
                 <load-on-startup>1</load-on-startup>
             </servlet>


             <servlet-mapping>
                 <servlet-name>my-service</servlet-name>
                 <url-pattern>/processFullDictionary/*</url-pattern>
             </servlet-mapping>

         </web-app>

This mapping produces an HTTP Error 404. enter image description here

By replacing the wildcard with an explicit URI, the servlet is correctly mapped and the error doesn't show up:

<servlet-mapping>
        <servlet-name>my-service</servlet-name>
        <url-pattern>/processFullDictionary/form/sense/etym/re/xr/subEntry/note</url-pattern>
    </servlet-mapping>

I'm using Jetty 9.4.11.v20180605 as a server. Any idea what could be the problem?

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • The syntax of that 404 error is not one produced by standard Jetty, that syntax appears to be from Jersey itself. Perhaps the 404 you are seeing is specifically Jersey complaining. Do you have any logs on the server side telling you anything useful? – Joakim Erdfelt Mar 03 '19 at 11:47
  • the server side is clean. As a workaround solution I have changed the url-pattern to *.processFullDictionary and I changed it the same way in the java class, as for my case processFullDictionary has no to be a prefix. Somehow it worked – user3621950 Mar 05 '19 at 16:57
  • `*.processFullDictionary` is a prefix / extension mapping url-pattern. see https://stackoverflow.com/a/14018272/775715 for more details on url-pattern options – Joakim Erdfelt Mar 05 '19 at 17:20

0 Answers0