Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-656

Context path without trailing slash doesn't work with ApplicationPath("/")

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.3.2.Final
    • 2.3.0.GA
    • jaxrs
    • None

    Description

      We have an application that uses the @ApplicationPath("/") annotation. The annotated class implements the "getSingletons()" method and one of those singletons has a @Path("/") annotation. The idea is having that resource available in the context root, so if the application is deployed to the context root "/api" we want that resource to be available when the user types the "http://whatever/api" URL. Unfortunately this does not work, it only works if the trailing slash is included: "http://whatever/api/".

      I think that the cause is in the "extractUriInfo" of the "org.jboss.resteasy.plugins.server.servlet.ServletUtil" class.

      The following patch apparently resolves the problem:

      — a/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/server/servlet/ServletUtil.java
      +++ b/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/server/servlet/ServletUtil.java
      @@ -34,7 +34,7 @@ public class ServletUtil
      public static UriInfoImpl extractUriInfo(HttpServletRequest request, String servletPrefix)
      {
      String contextPath = request.getContextPath();

      • if (servletPrefix != null && servletPrefix.length() > 0)
        + if (servletPrefix != null && servletPrefix.length() > 0 && !servletPrefix.equals("/"))
        {
        if (!contextPath.endsWith("/") && !servletPrefix.startsWith("/"))
        contextPath += "/";

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            juan.hernandez_jira Juan Hernández (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: