Groovy
  1. Groovy
  2. GROOVY-4660

NPE in groovy.servlet.AbstractHttpServlet if deploy WAR to jetty

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7.6
    • Fix Version/s: 1.8.6, 2.0-beta-3
    • Component/s: Groovlet / GSP
    • Labels:
      None
    • Environment:
      Jetty: 7.2.0.v20101020

      Description

      I have generated a (non-grails) war using gsp's mapped to groovy.servlet.TemplateServlet. If I deploy the War to Tomcat it works. If I unpack the war then it works in Jetty. But it fails with an NPE if I try to deploy it as a War with Jetty:

      2011-02-04 11:04:06.030:INFO:data-pump-comparator-04.04.01-dev:GroovyTemplate: Servlet groovy.servlet.TemplateServlet initialized on
      class groovy.text.GStringTemplateEngine
      2011-02-04 11:04:06.030:WARN::/data-pump-comparator-04.04.01-dev/
      java.lang.NullPointerException
      at java.io.File.<init>(File.java:222)
      at groovy.servlet.AbstractHttpServlet.getScriptUriAsFile(AbstractHttpServlet.java:306)
      at groovy.servlet.TemplateServlet.service(TemplateServlet.java:388)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:533)
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:475)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)

      I think this is down to a problm in groovy.servlet.AbstractHttpServlet

      TemplateServlet.service does this:

      File file = super.getScriptUriAsFile(request);

      AbstractHttpServlet.getScriptUriAsFile does this:
      String uri = getScriptUri(request);
      String real = servletContext.getRealPath(uri);
      return new File(real).getAbsoluteFile();

      The Javadocs for javax.servlet.ServletContext.getRealPath say:

      • This method returns null
      • if the servlet container cannot translate the virtual path
      • to a real path for any reason (such as when the content is
      • being made available from a .war archive).

      I think that is why the failure happens. AFAIK it also happens with WebLogic (http://groovy.329449.n5.nabble.com/Groovlet-GSP-NPE-when-deployed-as-a-war-to-Weblogic-td3320802.html)

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Guillaume Delcroix
            Reporter:
            Paul Cager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development