Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError exception while running basic Groovy script from console

Tags:

java-9

groovy

I'm getting below exception while running basic groovy script from console after installation. For installation I have used the installer:

Java version: jdk-9.0.1 , jre-9.0.1

Exception thrown

java.lang.NoClassDefFoundError: Unable to load class groovy.xml.jaxb.JaxbGroovyMethods due to missing dependency javax/xml/bind/Marshaller

    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)
like image 458
Saianil Kumarreddy Avatar asked May 30 '26 21:05

Saianil Kumarreddy


1 Answers

Java 9 doesn't package the 'javax.xml' by default. Add --add-modules java.xml.bind to your command line argument when running.

See How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9

like image 52
Ben Harris Avatar answered Jun 02 '26 12:06

Ben Harris