Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.7.6
-
None
-
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)