Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 1.7-beta-2
-
Fix Version/s: 1.7-rc-1
-
Component/s: Groovlet / GSP
-
Labels:None
-
Environment:fedora 11/tomcat 6/
OpenJDK Runtime Environment (IcedTea6 1.6) (fedora-29.b16.fc11-x86_64)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
-
Number of attachments :
Description
I create web application, which can be simplicified to 'groovy-all-1.7-beta2.jar' in lib, web.xml with standard
GroovyServlet definition:
---------------------------
<servlet>
<servlet-name>Groovy</servlet-name>
<servlet-class>groovy.servlet.GroovyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Groovy</servlet-name>
<url-pattern>*.groovy</url-pattern>
</servlet-mapping>
------------------------------
and x.groovy with next text:
--------------------------
import java.util.Date
import groovy.xml.MarkupBuilder
def expr="";
def result="";
if (request.getParameter("expr")!=null) {
expr=request.getParameter("expr");
}
html.html{
body{
form(id:"console_form", method:"post"){
table{
tr{
td{textarea(name:"expr",cols:120, rows:6, "$
")}
}
tr{
td
}
tr{
td{textarea(name:"result",cols:120, rows:10, disabled:true,
"$
")}
}
}
}
}
}
----------------------------------
than, ater typing url: http://127.0.0.1:8080/ifs/x.groovy
at first type, form is show, after submit (which must go on same URL) I see 404 page
with message in catalina.out:
INFO: GroovyServlet Error: script: '/x.groovy': Script not found, sending 404.
GroovyServlet Error: script: '/x.groovy': Script not found, sending 404.
Note, that bug is specific to 1.7-beta-2. in 1.6.1 all work as expected.
If more information is needed, I can prepare war file with stripped-down application.
I was able to reproduce the issue and solve it using the current patch. I need someone to review it please.
The issue was related to the name with which GroovyScriptEngine maintains its scriptCache (introduce in some recent dependency checking logic in GSE). When GroovyScriptEngine loads a script by name '/x.groovy', it opens a URLConnection and caches the compiled class with the URLConnection path, which is like '/localhost/myapp/x.groovy' (with tomcat 6). When the request is submitted again, it tries to do the timestamp check to see if script has a newer timestamp, and there it tries to do servletContext.getResource("/" + "/localhost/myapp/x.groovy"), with "/localhost/myapp/x.groovy" being the dependency name in scriptCache, and it becomes wrong because it should actually just be servletContext.getResource("/" + "/x.groovy").
servletContext.getResource("/" + "/localhost/myapp/x.groovy") fails with ResourceNotFound exception resulting in 404 messages.
So, instead of interfering with caching logic of GroovyScriptEngine, which can affect other places too, I have fixed it in groovy.servlet.AbstractHttpServlet#getResourceConnection() itself to remove the base virtual path from dependency name, if it is found.