Я пытаюсь запустить этот Groovy-скрипт (который отлично работает на Java 8) на сервере, на котором установлена Java 10.
@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.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" })
}
}
Но я всегда получаю ошибку отсутствия зависимости:
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 release
Caught: 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)