0

Windows 10 OS, Java 9, Groovy 2.5.7 (newly upgraded)

I launch the Groovy Console, and run this

println "hello"

I get this exception

Exception thrown

java.lang.NoClassDefFoundError: Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext

    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)

There's an answer here about this, though not Groovy-specific, even less Groovy-Console-specific.

I tried the following lines as line 1:

@Grab( "javax.xml.bind:jaxb-api:2.2.11" )

then

@Grab( "javax.xml.bind" )

... both of these gave

1 compilation error:

unexpected token: println at line: 3, column: 1

(i.e. the println line)

mike rodent
  • 14,126
  • 11
  • 103
  • 157
  • I can't help with groovy. Basically the needed class is not part of java anymore so you need to add it as a dependency. If you just switched zo java 9 consider java 11 as 9 and 10 are not supported widely. – NielsNet Jun 02 '19 at 10:23
  • 1
    Thanks. Yes, I'm aware of both your points. Java 11 is meant to be "LTS" but I feel like I should do a bit of time experimenting with Java 9 - in fact I don't really understand why there's been such a burst of activity with 9, 10, 11 and now 12 (seemingly with a suspicious change of licence). Re adding dependencies: fine in the context of a Gradle project, but I don't know how to do this for the Groovy console. – mike rodent Jun 02 '19 at 10:33

0 Answers0