groovlet 用のキャッチオール 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.
最初のクラスが生成されるのはなぜですか? 私のコードには他のクラスはありません。キャッチオール スクリプトと拡張サーブレットのみ。
これは、上記のエラーが発生した削除されたコードでした
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)
ここにも同じ質問を投稿しました