我正在尝试为我的 groovlet 使用 Catch-all groovy 脚本。这就是我所做的
public class GroovletServletCatchAll extends GroovyServlet {
public URLConnection getResourceConnection(String name) throws ResourceException {
return super.getResourceConnection("CatchAll.groovy");
}
}
现在,使用CatchAll.groovy
文件中的任何代码,我得到了错误
jndi:/localhost/web_app/CatchAll.groovy: 1:
Invalid duplicate class definition of class CatchAll.
One of the classes is an explicit generated class using the class statement,
the other is a class generated from the script body based on the file name.
为什么生成第一类?我的代码中没有任何其他类。只有 Catch-all 脚本和扩展的 servlet。
这是我得到上述错误的剥离代码
println """
Hello, ${request.remoteHost}: ${new Date()}
"""
奇怪的是,如果我删除new Date()
上面的子句,第一个错误就会消失,并且我在 CatchAll 构造函数中得到一个 stackOverflow(继续调用自身)。
这就是我在日志中看到的重复(以及其他痕迹)
at groovy.lang.GroovyObjectSupport.<init>(GroovyObjectSupport.java:32)
at groovy.lang.Script.<init>(Script.java:40)
at groovy.lang.Script.<init>(Script.java:37)
at CatchAll.<init>(CatchAll.groovy)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
我也在这里发布了同样的问题