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

        Paul Cager created issue -
        Paul Cager made changes -
        Field Original Value New Value
        Attachment GROOVY-4660.patch [ 53635 ]
        Guillaume Delcroix made changes -
        Assignee Guillaume Laforge [ guillaume ]
        Guillaume Delcroix made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0-beta-3 [ 18244 ]
        Fix Version/s 1.8.6 [ 18245 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733592 ] Default workflow, editable Closed status [ 12745400 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12972883 ] Default workflow, editable Closed status [ 12974279 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development