itplr-kosit / validator

Validates XML documents with XML Schema and Schematron
Apache License 2.0
80 stars 42 forks source link

java.lang.NoSuchMethodException using Java 17 #94

Closed felixxxxxs closed 1 year ago

felixxxxxs commented 2 years ago

Using standalone validator version 1.4.2 With Java 17:

openjdk version "17.0.2" 2022-01-18 LTS
OpenJDK Runtime Environment Zulu17.32+13-CA (build 17.0.2+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.32+13-CA (build 17.0.2+8-LTS, mixed mode, sharing)

If this error is because of Java 17, the "standalone" build should definitely be updated to support it :)

Running the validator produces the following output:

KoSIT Validator version 1.4.2
Loading scenarios from  file:///C:/Users/Felix/Desktop/validator/scenarios.xml
Using repository  null
Mõrz 03, 2022 9:30:32 PM com.sun.xml.bind.v2.runtime.reflect.opt.Injector <clinit>
SCHWERWIEGEND: null
java.security.PrivilegedActionException: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:573)
        at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.<clinit>(Injector.java:166)
        at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:51)
        at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:157)
        at com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection.optimize(Accessor.java:255)
        at com.sun.xml.bind.v2.runtime.property.ArrayProperty.<init>(ArrayProperty.java:38)
        at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.<init>(ArrayERProperty.java:58)
        at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.<init>(ArrayElementProperty.java:70)
        at com.sun.xml.bind.v2.runtime.property.ArrayElementNodeProperty.<init>(ArrayElementNodeProperty.java:32)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
        at com.sun.xml.bind.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:99)
        at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:150)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:493)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:310)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:109)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1142)
        at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:144)
        at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:268)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:171)
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:129)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:307)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:478)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:435)
        at de.kosit.validationtool.impl.ConversionService.initialize(ConversionService.java:143)
        at de.kosit.validationtool.impl.ConversionService.initialize(ConversionService.java:133)
        at de.kosit.validationtool.impl.ConversionService.initialize(ConversionService.java:117)
        at de.kosit.validationtool.impl.ConversionService.getJaxbContext(ConversionService.java:89)
        at de.kosit.validationtool.impl.ConversionService.readXml(ConversionService.java:180)
        at de.kosit.validationtool.config.ConfigurationLoader.loadScenarios(ConfigurationLoader.java:171)
        at de.kosit.validationtool.config.ConfigurationLoader.build(ConfigurationLoader.java:139)
        at de.kosit.validationtool.cmd.Validator.processActions(Validator.java:173)
        at de.kosit.validationtool.cmd.Validator.mainProgram(Validator.java:105)
        at de.kosit.validationtool.cmd.CommandLineApplication.mainProgram(CommandLineApplication.java:92)
        at de.kosit.validationtool.cmd.CommandLineApplication.main(CommandLineApplication.java:60)
Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
        at java.base/java.lang.Class.getMethod(Class.java:2227)
        at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:170)
        at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:166)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
        ... 41 more

Cannot invoke "java.lang.reflect.Method.invoke(Object, Object[])" because "com.sun.xml.bind.v2.runtime.reflect.opt.Injector.defineClass" is null

##############################
#     Validation failed!     #
##############################
ubabap commented 2 years ago

I have the same issue. Forcing using old java 8 is solving the issue. So please at least update the written compatibility from JAVA > 10 to the dedicated Versions the tool is able tun run in.

apenski commented 1 year ago

Problem solved by upgrade the jaxb dependency. Fixed in main

wq9578 commented 1 year ago

The problem still persists:

➜  XR java -jar validationtool-1.4.2-standalone.jar -s scenarios.xml -h ubl.xml 
KoSIT Validator version 1.4.2
Loading scenarios from  file:///Users/mac/tmp/XR/scenarios.xml
Using repository  null
Dez. 27, 2022 11:15:59 PM com.sun.xml.bind.v2.runtime.reflect.opt.Injector <clinit>
SCHWERWIEGEND: null
java.security.PrivilegedActionException: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:573)
    at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.<clinit>(Injector.java:166)
    at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:51)
    at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:157)
    at com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection.optimize(Accessor.java:255)
    at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.<init>(SingleElementNodeProperty.java:64)
    at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
    at com.sun.xml.bind.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:99)
    at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:150)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:493)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:310)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:109)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1142)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:144)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:268)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:171)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:129)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:307)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:478)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:435)
    at de.kosit.validationtool.impl.ConversionService.initialize(ConversionService.java:143)
    at de.kosit.validationtool.impl.ConversionService.initialize(ConversionService.java:133)
    at de.kosit.validationtool.impl.ConversionService.initialize(ConversionService.java:117)
    at de.kosit.validationtool.impl.ConversionService.getJaxbContext(ConversionService.java:89)
    at de.kosit.validationtool.impl.ConversionService.readXml(ConversionService.java:180)
    at de.kosit.validationtool.config.ConfigurationLoader.loadScenarios(ConfigurationLoader.java:171)
    at de.kosit.validationtool.config.ConfigurationLoader.build(ConfigurationLoader.java:139)
    at de.kosit.validationtool.cmd.Validator.processActions(Validator.java:173)
    at de.kosit.validationtool.cmd.Validator.mainProgram(Validator.java:105)
    at de.kosit.validationtool.cmd.CommandLineApplication.mainProgram(CommandLineApplication.java:92)
    at de.kosit.validationtool.cmd.CommandLineApplication.main(CommandLineApplication.java:60)
Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
    at java.base/java.lang.Class.getMethod(Class.java:2277)
    at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:170)
    at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:166)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
    ... 34 more

Cannot invoke "java.lang.reflect.Method.invoke(Object, Object[])" because "com.sun.xml.bind.v2.runtime.reflect.opt.Injector.defineClass" is null

##############################
#     Validation failed!     #
##############################
➜  XR java -version                                                                     
openjdk version "19.0.1" 2022-10-18
OpenJDK Runtime Environment Homebrew (build 19.0.1)
OpenJDK 64-Bit Server VM Homebrew (build 19.0.1, mixed mode, sharing)
➜  XR sw_vers 
ProductName:    macOS
ProductVersion: 12.6.2
BuildVersion:   21G320
➜  XR 
apenski commented 1 year ago

well, fixed in 1.5.0, not in 1.4.2.

wq9578 commented 1 year ago

Thanks, it now works with v1.5.0. However, I had to specify an absolute path, which should be avoided. See No. 3 here: https://github.com/itplr-kosit/validator-configuration-xrechnung/issues/80