JL_SO
JL_SO

Reputation: 1901

Executing scripts in groovyconsole with Java 11 generates missing JAXB dependency exception

I have seen other questions on this but the vast majority of answers specify setting dependencies POM.xml files i.e. for running groovy scripts in e.g. Intellij. I am simply trying to get groovyconsole (in windows) to execute a one line print command but despite trying various permutations of setting JAVA_OPTS nothing is working. When I set JAVA_OPTS the groovyconsole completely fails to launch.

groovyconsole

My java version is jdk 11, my groovy version is 3.0. I thought all this was supposed to have been solved back in groovy 2.6 or thereabouts.

C:\Users\J\Documents\Development>java -version
java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)

C:\Users\J\Documents\Development>javac -version
javac 11.0.5

C:\Users\J\Documents\Development>echo %JAVA_HOME%
C:\Program Files\Java\jdk-11.0.5    

C:\Users\J\Documents\Development>groovy --version
Groovy Version: 3.0.0-beta-3 JVM: 11.0.5 Vendor: Oracle Corporation OS: Windows 10

If you refer me to another question please do ensure that there is an answer there that actually solves this particular issue because despite trawling through them I cannot find an answer for running just groovyconsole with Java 11. I repeat this question concerns running groovyconsole alone, not any groovy stuff in intellij.

I have tried setting JAVA_OPTS on the command line (eg set JAVA_OPTS=--add-modules java.xml.bind); I have tried supplying JAVA_OPTS when invoking groovyconsole (eg groovyconsole -DJAVA_OPTS=--add-modules java.xml.bind). When I do this groovyconsole simply fails to launch. Or perhaps it does launch but terminates before I can even see the window launching.

I have also tried the same with _JAVA_OPTS but that makes no difference; it's as if it's not even used/read when launching groovyconsole.

I am at the point now where I have spent hours and hours on this issue which really is quite ridiculous so it's time to ask for help.

Edit I have also just tried the following, both of which 'allow' the groovyconsole to launch but neither of which fixes the issue

C:\Users\J\Documents\Development>groovyconsole -D"JAVA_OPTS=--add-modules ALL-SYSTEM"
C:\Users\J\Documents\Development>groovyconsole -D"JAVA_OPTS=--add-modules java.xml.bind"

Edit I have also just tried the following, and they both prevent the console from launching at all:

C:\Users\J\Documents\Development>set JAVA_OPTS="--add-modules java.xml.bind"
C:\Users\J\Documents\Development>set JAVA_OPTS="--add-modules ALL-SYSTEM"

Upvotes: 1

Views: 1415

Answers (1)

Ken DeLong
Ken DeLong

Reputation: 961

There's a bug about this filed in the Groovy JIRA, but it was closed https://issues.apache.org/jira/browse/GROOVY-9305 I found that if I moved the groovy-jaxb.jar file out of the lib dir, the console worked.

However, I note the font has changed (from 2.5.7 to 2.5.8) to a more janky looking fixed-width font. It makes me suspect something is still amiss. I use the groovyconsole a LOT so I'm a bit nervous...

EDIT I found out that I had a postInit.bat file in %HOME%/.groovy. This file had the line

SET JAVA_OPTS=-Xmx1g -Dgroovy.console.output.limit=200000

I had to change that to

SET JAVA_OPTS=%JAVA_OPTS% -Xmx1g -Dgroovy.console.output.limit=200000

because the startGroovy.bat file in %GROOVY_HOME%/bin adds the property -Dgroovy.jaxb=jaxb. My previous version of the file was erasing the JAVA_OPTS set by Groovy.

Upvotes: 1

Related Questions