You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Christian C <ch...@gmail.com> on 2018/05/26 11:32:02 UTC
jaxb dependency issue with groovy 2.5 b3 and java 10
hello
I have asked this question on stackoverflow as i thought i might just need
to add some other dependency. however some user mentioned to also ask the
groovy developers if this could be a potential bug.
https://stackoverflow.com/questions/50540710/groovy-2-5-java-10-and-sparkjava
I try to run this groovy script (which runs fine on java 8) on a server
which ahs java 10 installed an always get a dependency missing error
reported.
Thx
Christian
@Grapes([
@Grab(group='org.slf4j', module='slf4j-api', version='1.7.25'),
@Grab(group='ch.qos.logback', module='logback-classic',
version='1.2.3'),
@Grab(group='org.apache.commons', module='commons-lang3',
version='3.7'),
@Grab(group='com.sparkjava', module='spark-core', version='2.7.2'),
@Grab(group='javax.xml.bind', module='jaxb-api', version='2.3.0'),
@Grab(group='com.sun.xml.bind', module='jaxb-core', version='2.3.0'),
@Grab(group='com.sun.xml.bind', module='jaxb-impl',
version='2.3.0')])import groovy.json.JsonOutputimport
groovy.json.JsonSlurperimport groovy.util.logging.Slf4jimport
org.apache.commons.lang3.exception.ExceptionUtilsimport
spark.Routeimport static spark.Spark.*
@Slf4jclass Server {
public static void main(String[] args) {
int serverPort = args.length > 0 ? args[0].toInteger() : 1001
log.info("start server at $serverPort ... ")
port(serverPort)
get("/hello", { req, rep -> "world" })
}}
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
org.codehaus.groovy.vmplugin.v7.Java7$1
(file:/opt/groovy-2.5.0-rc-3/lib/groovy-2.5.0-rc-3.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
releaseCaught: java.lang.NoClassDefFoundError: Unable to load class
groovy.xml.jaxb.JaxbGroovyMethods due to missing dependency
javax/xml/bind/JAXBContext
java.lang.NoClassDefFoundError: Unable to load class
groovy.xml.jaxb.JaxbGroovyMethods 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)
Re: jaxb dependency issue with groovy 2.5 b3 and java 10
Posted by Paul King <pa...@asert.com.au>.
JDK9 removed the JAXB classes that were present in JDK8. Follow the
standard advice on adding back such a module, e.g.:
https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j
I used:
> set JAVA_OPTS=--add-modules java.xml.bind
Then I ran the equivalent of your script with no problems in the
GroovyConsole:
====
@Grab('org.slf4j:slf4j-api:1.7.23')
@Grab('ch.qos.logback:logback-classic:1.2.3')
@Grab('org.apache.commons:commons-lang3:3.7')
@Grab('com.sparkjava:spark-core:2.7.2')
@Grab('javax.xml.bind:jaxb-api:2.3.0')
@Grab('com.sun.xml.bind:jaxb-core:2.3.0')
@Grab('com.sun.xml.bind:jaxb-impl:2.3.0')
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import groovy.util.logging.Slf4j
import org.apache.commons.lang3.exception.ExceptionUtils
import spark.Route
import static spark.Spark.*
@Slf4j
class Server {
public static void main(String[] args) {
int serverPort = args.length > 0 ? args[0].toInteger() : 1001
log.info("start server at $serverPort ... ")
port(serverPort)
get("/hello", { req, rep -> "world" })
}
}
====
You get the error because Groovy's groovy-xml module provides some
enhancements
to JAXB and they rely on those previously available classes. Currently the
enhancement class
is loaded automatically at startup. A future version of Groovy will work
around this issue.
If you are not using any Groovy XML features, you can alternatively just
remove the
groovy-xml jar from your distribution - that's probably a little brutal
workaround for many
users but would be fine with your example.
Cheers, Paul.
On Sat, May 26, 2018 at 9:32 PM, Christian C <ch...@gmail.com> wrote:
> hello
>
> I have asked this question on stackoverflow as i thought i might just need
> to add some other dependency. however some user mentioned to also ask the
> groovy developers if this could be a potential bug.
>
> https://stackoverflow.com/questions/50540710/groovy-2-5-
> java-10-and-sparkjava
>
> I try to run this groovy script (which runs fine on java 8) on a server
> which ahs java 10 installed an always get a dependency missing error
> reported.
>
> Thx
> Christian
>
>
> @Grapes([
> @Grab(group='org.slf4j', module='slf4j-api', version='1.7.25'),
> @Grab(group='ch.qos.logback', module='logback-classic', version='1.2.3'),
> @Grab(group='org.apache.commons', module='commons-lang3', version='3.7'),
> @Grab(group='com.sparkjava', module='spark-core', version='2.7.2'),
> @Grab(group='javax.xml.bind', module='jaxb-api', version='2.3.0'),
> @Grab(group='com.sun.xml.bind', module='jaxb-core', version='2.3.0'),
> @Grab(group='com.sun.xml.bind', module='jaxb-impl', version='2.3.0')])import groovy.json.JsonOutputimport groovy.json.JsonSlurperimport groovy.util.logging.Slf4jimport org.apache.commons.lang3.exception.ExceptionUtilsimport spark.Routeimport static spark.Spark.*
> @Slf4jclass Server {
> public static void main(String[] args) {
> int serverPort = args.length > 0 ? args[0].toInteger() : 1001
> log.info("start server at $serverPort ... ")
> port(serverPort)
>
> get("/hello", { req, rep -> "world" })
> }}
>
> WARNING: An illegal reflective access operation has occurred
> WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/opt/groovy-2.5.0-rc-3/lib/groovy-2.5.0-rc-3.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 releaseCaught: java.lang.NoClassDefFoundError: Unable to load class groovy.xml.jaxb.JaxbGroovyMethods due to missing dependency javax/xml/bind/JAXBContext
> java.lang.NoClassDefFoundError: Unable to load class groovy.xml.jaxb.JaxbGroovyMethods 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)
>
>