You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Martin d'Anjou <ma...@gmail.com> on 2021/01/08 18:16:21 UTC

@Grab issue with groovy 3 but okay in groovy 2

This code works in groovy 2, but not in groovy 3.

@Grab(group='org.antlr', module='ST4', version='4.3.1')
import org.stringtemplate.v4.*
ST hello = new ST("Hello, <name>");
hello.add("name", "World");
println(hello.render());

Groovy 2:
$ groovy --version
Groovy Version: 2.5.14 JVM: 11.0.9.1 Vendor: AdoptOpenJDK OS: Linux
$ groovy st.groovy
Hello, World

Groovy 3:
$ groovy --version
Groovy Version: 3.0.5 JVM: 11.0.9.1 Vendor: AdoptOpenJDK OS: Linux
$ groovy st.groovy
Caught: java.lang.NoClassDefFoundError: org/antlr/runtime/Token
java.lang.NoClassDefFoundError: org/antlr/runtime/Token
        at org.stringtemplate.v4.ST.<init>(ST.java:159)
        at
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at
java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at st.run(st.groovy:4)
        at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Caused by: java.lang.ClassNotFoundException: org.antlr.runtime.Token
        ... 8 more

I don't understand why. Can someone help me please?

Thanks,
Martin

Re: @Grab issue with groovy 3 but okay in groovy 2

Posted by Paul King <pa...@asert.com.au>.
I haven't found the relevant issue/commit yet but seems fixed in 3.0.7.

Cheers, Paul.

On Sat, Jan 9, 2021 at 4:16 AM Martin d'Anjou <ma...@gmail.com>
wrote:

> This code works in groovy 2, but not in groovy 3.
>
> @Grab(group='org.antlr', module='ST4', version='4.3.1')
> import org.stringtemplate.v4.*
> ST hello = new ST("Hello, <name>");
> hello.add("name", "World");
> println(hello.render());
>
> Groovy 2:
> $ groovy --version
> Groovy Version: 2.5.14 JVM: 11.0.9.1 Vendor: AdoptOpenJDK OS: Linux
> $ groovy st.groovy
> Hello, World
>
> Groovy 3:
> $ groovy --version
> Groovy Version: 3.0.5 JVM: 11.0.9.1 Vendor: AdoptOpenJDK OS: Linux
> $ groovy st.groovy
> Caught: java.lang.NoClassDefFoundError: org/antlr/runtime/Token
> java.lang.NoClassDefFoundError: org/antlr/runtime/Token
>         at org.stringtemplate.v4.ST.<init>(ST.java:159)
>         at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>         at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>         at
> java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>         at st.run(st.groovy:4)
>         at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>         at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> Caused by: java.lang.ClassNotFoundException: org.antlr.runtime.Token
>         ... 8 more
>
> I don't understand why. Can someone help me please?
>
> Thanks,
> Martin
>
>