Cephos
Cephos

Reputation: 358

Can't launch Groovy Console - missing dependency javax/xml/bind/Unmarshaller

Groovy version: 2.5.1 Java version: 10.0.2

Trying to launch the groovyConsole I get the following:

$ groovyConsole
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/usr/local/opt/groovy/libexec/lib/groovy-2.5.1.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
java.lang.reflect.InvocationTargetException
        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)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:114)
        at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:136)
Caused by: java.lang.NoClassDefFoundError: Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/Unmarshaller
        at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:407)
        at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:280)
        at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:400)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache.scanExtClasses(MacroMethodsCache.java:88)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache.access$000(MacroMethodsCache.java:45)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache$2.onModule(MacroMethodsCache.java:69)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromProperties(ExtensionModuleScanner.java:87)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromMetaInf(ExtensionModuleScanner.java:81)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanClasspathModulesFrom(ExtensionModuleScanner.java:63)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanClasspathModules(ExtensionModuleScanner.java:54)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache.getMacroMethodsFromClassLoader(MacroMethodsCache.java:76)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache$1.provide(MacroMethodsCache.java:53)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache$1.provide(MacroMethodsCache.java:50)
        at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147)
        at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:123)
        at org.codehaus.groovy.macro.transform.MacroMethodsCache.get(MacroMethodsCache.java:50)
        at org.codehaus.groovy.macro.transform.MacroCallTransformingVisitor.findMacroMethods(MacroCallTransformingVisitor.java:118)
        at org.codehaus.groovy.macro.transform.MacroCallTransformingVisitor.visitMethodCallExpression(MacroCallTransformingVisitor.java:89)
        at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:70)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:122)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:197)
        at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)

plus more.......................................

Upvotes: 23

Views: 20409

Answers (5)

David
David

Reputation: 1

In case someone has had the same problem and other solutions didn't help, here what helped me:

  • Added "jaxb" dependency to my project.

  • Go to Run -> Edit configurations -> Templates -> Gradle -> In Gradle Project choose your own application.

Upvotes: 0

ranma2913
ranma2913

Reputation: 1206

I was able to solve this by adding the jaxb module to my gradle file. I like this solution because it changes your project configuration file instead of going into the IDE settings.

dependencies {
  implementation group: 'org.codehaus.groovy', name: 'groovy-all', version: '3.0.1'
  implementation group: 'org.codehaus.groovy', name: 'groovy-jaxb', version: '3.0.1'
}

Upvotes: 0

Ying Chen
Ying Chen

Reputation: 405

Also got the same issue when using java 11.0.2 and groovy 2.5.5 in IntelliJ.

Found this post that helps! https://www.logicbig.com/tutorials/misc/groovy/intellij.html

Basically have to add JAXB dependencies

Also you have to add JAXB dependencies if you are using Groovy 2.5.3 + Java 11 (also check out Java 11 related change). Groovy comes with extra JAXB Jars so we can add them. Open 'Project Structure' dialog, then select 'Dependencies' tab and add the dependencies as shown

Upvotes: 38

Dzmitry Hubin
Dzmitry Hubin

Reputation: 1301

I've also got this when I debugged some my groovy scripts with groovy 2.5.4 and java 10.

Setting JAVA_OPTS=--add-modules java.xml.bind solved the mentioned problem for me.

Upvotes: 1

Paul King
Paul King

Reputation: 1026

Three suggestions are in the release notes for 2.5.1:

http://groovy-lang.org/releasenotes/groovy-2.5.html#Groovy2.5releasenotes-Addendum251

In 2.5.2, probably a week or two away, you won't need to do them - grab the snapshot version from the CI server if you want to try it out now.

Upvotes: 3

Related Questions