[groovy-user] extending Java HttpServlet

0 views
Skip to first unread message

Andrew Gaydenko

unread,
Nov 22, 2007, 8:26:51 AM11/22/07
to us...@groovy.codehaus.org
Hi!

I try to extend java HttpServlet with Groovy class. All works fine until some
webapp jars are needed. In particular, WEB-INF/lib contains ANTLR3 runtime
jar, but Tomcat isn't happy (trace fragment is below).

Some tips and tricks?


Andrew

----------------------
java.lang.NoClassDefFoundError: antlr/RecognitionException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at
org.codehaus.groovy.reflection.CachedClass.getMethods(CachedClass.java:131)
at groovy.lang.MetaClassImpl.populateMethods(MetaClassImpl.java:238)
at groovy.lang.MetaClassImpl.fillMethodIndex(MetaClassImpl.java:217)
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:2380)
at
org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:164)
at org.codehaus.groovy.runtime.Invoker.invokeConstructorOf(Invoker.java:125)
at
org.codehaus.groovy.runtime.InvokerHelper.invokeConstructorOf(InvokerHelper.java:95)
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNewN(ScriptBytecodeAdapter.java:245)
...

---------------------------------------------------------------------
To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Jürgen Hermann

unread,
Nov 22, 2007, 8:42:05 AM11/22/07
to us...@groovy.codehaus.org
try to use groovy-all.jar, which contains a jarjar'd antlr, avoiding the collision.

Andrew Gaydenko

unread,
Nov 22, 2007, 8:46:06 AM11/22/07
to us...@groovy.codehaus.org
======= On Thursday 22 November 2007, Jürgen Hermann wrote: =======

> try to use groovy-all.jar, which contains a jarjar'd antlr, avoiding the
> collision.

WEB-INF/lib contains almost last (b893) groovy-all (with all jarjars)
snapshot.

Andrew Gaydenko

unread,
Nov 22, 2007, 9:00:02 AM11/22/07
to us...@groovy.codehaus.org
======= On Thursday 22 November 2007, Andrew Gaydenko wrote: =======

> ======= On Thursday 22 November 2007, Jürgen Hermann wrote: =======
>
> > try to use groovy-all.jar, which contains a jarjar'd antlr, avoiding the
> > collision.
>
> WEB-INF/lib contains almost last (b893) groovy-all (with all jarjars)
> snapshot.
>

Small addition. I have tried to use other external jar (javax.mail), a tried
class was found. So, it seems to be an ANTLR-related issue.

To be more talking - my Groovy extention od Java HttpServlet calls a chain of
other Groovy classes, at some point some of them calls java (also my) class,
and last one use ANTLR. I use compiled Groovy classes rather scripting.

Jochen Theodorou

unread,
Nov 22, 2007, 9:13:54 AM11/22/07
to us...@groovy.codehaus.org
Andrew Gaydenko schrieb:

> ======= On Thursday 22 November 2007, Andrew Gaydenko wrote: =======
>> ======= On Thursday 22 November 2007, Jürgen Hermann wrote: =======
>>
>>> try to use groovy-all.jar, which contains a jarjar'd antlr, avoiding the
>>> collision.
>> WEB-INF/lib contains almost last (b893) groovy-all (with all jarjars)
>> snapshot.

there should be only one groovy-all jar and it would be best if you
remove all jars you don't really need.

> Small addition. I have tried to use other external jar (javax.mail), a tried
> class was found. So, it seems to be an ANTLR-related issue.
>
> To be more talking - my Groovy extention od Java HttpServlet calls a chain of
> other Groovy classes, at some point some of them calls java (also my) class,
> and last one use ANTLR. I use compiled Groovy classes rather scripting.

from the trace I see that you have a "new ..." in Groovy code and this
class needs ANTLR to load. SO far so good...
Does WEB-INF/lib contain only one antlr jar? If not remove all but one.

bye blackdrag

--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/

Andrew Gaydenko

unread,
Nov 22, 2007, 9:21:08 AM11/22/07
to us...@groovy.codehaus.org
======= On Thursday 22 November 2007, Jochen Theodorou wrote: =======

> there should be only one groovy-all jar and it would be best if you
> remove all jars you don't really need.

This case takes place.

> from the trace I see that you have a "new ..." in Groovy code and this
> class needs ANTLR to load. SO far so good...
> Does WEB-INF/lib contain only one antlr jar? If not remove all but one.

# pwd
/wrk/usr/eclipse/projects/GS/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/xtestweb/WEB-INF/lib
# ls
activation-1.1.jar antlr-runtime-3.0.1.jar groovy-all-893.jar
mail-1.4.1.jar xlib.jar


Andrew

Jochen Theodorou

unread,
Nov 22, 2007, 9:43:23 AM11/22/07
to us...@groovy.codehaus.org
Andrew Gaydenko schrieb:

> ======= On Thursday 22 November 2007, Jochen Theodorou wrote: =======
>> there should be only one groovy-all jar and it would be best if you
>> remove all jars you don't really need.
>
> This case takes place.
>
>> from the trace I see that you have a "new ..." in Groovy code and this
>> class needs ANTLR to load. SO far so good...
>> Does WEB-INF/lib contain only one antlr jar? If not remove all but one.
>
> # pwd
> /wrk/usr/eclipse/projects/GS/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/xtestweb/WEB-INF/lib
> # ls
> activation-1.1.jar antlr-runtime-3.0.1.jar groovy-all-893.jar
> mail-1.4.1.jar xlib.jar

ok, I took a look ant the antlr runtime and... well there is no
antlr.RecognitionException, there is not even a antlr package. Instead
it is in org.antlr.rntime.RecognitionException

So I guess you compiled against an ANTLR before 3.0. 3.0 is no simple
update, it is a complete rework of ANTLR.

bye blackdrag

--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/

---------------------------------------------------------------------

Andrew Gaydenko

unread,
Nov 22, 2007, 10:25:19 AM11/22/07
to us...@groovy.codehaus.org
======= On Thursday 22 November 2007, Jochen Theodorou wrote: =======
...

> So I guess you compiled against an ANTLR before 3.0. 3.0 is no simple
> update, it is a complete rework of ANTLR.
>
> bye blackdrag

Jochen, thanks! Indeed, ANTLR2 was included (but not exported in Eclipse
meaning of export) to a lib-project, from which the web-project depends on.
ANTLR2 is needed to generate parsers from grammar files (which was done with
Groovy class also :-) ). After removing ANTLR2-related jars from the
lib-project dependencies all works fine.


Thanks again!
Andrew

Reply all
Reply to author
Forward
0 new messages