Does GroovyServlet return 404 for all requests after a successful download once?

I have a Groovy script at the root of my web application that is served by Tomcat 7.0.22. The script is served by GroovyServlet from Groovy 1.8.4. When I launch the application through the Tomcat "manager" application, I can send a script request and return 200. Without changing anything, I can send a second request and return 404. Each request after the first request leads to 404 until I restart the application. The only thing that is recorded in the Catalina.out log is:

GroovyServlet Error: script: '/test.groovy': Script not found, sending 404. 

How can I either 1) solve this problem, or 2) go about debugging? I looked at the GroovyServlet source code for any possible web.xml configuration options for debugging, but I can't see them.

To be clear, my application web directory:

 /test.groovy /WEB-INF/lib/*.jar /WEB-INF/groovy/classes*.groovy /WEB-INF/web.xml 
+4
source share
2 answers

GroovyServlet must allow .groovy scripts to be hosted either in a regular web root web application or in / WEB -INF / groovy /. However, I saw a couple of times when scripts are not resolved if in the root folder. Try moving the .groovy scripts to / WEB-INF / groovy / and restarting Tomcat.

This is the configuration I'm using to deploy groovy scripts on Tomcat and Google App Engine. It usually works with groovy from 1.8.4 to 2.0.1, however, I see some problems with groovy 2.0.2, 2.0.4 and 2.0.5, not allowing scripts as you describe. I will continue to use groovy 2.0.1 until the GroovyServlet errors are fixed.

http://groovy.codehaus.org/api/groovy/servlet/GroovyServlet.html

UPDATE: The bug described above with groovy scripts in the web root or / WEB -INF / groovy in groovy 2.0.6 has been fixed.

+1
source

Changing line 501/491 in Groovy 1.8.8 / 2.0.2 to groovy / util / GroovyScriptEngine from

String path = conn.getURL().toExternalForm();

to

String path = conn.getURL().getPath();

fixes the problem for me.

0
source

Source: https://habr.com/ru/post/1382513/


All Articles