Skip to content

Compiler execution fails using Java 10 #226

Open

Description

@firefligher

Hi,
unfortunately the latest compiler binary (jsonix-schema-compiler-full.jar, via NPM, version 3.0.0) does not run out of the box with Java 10 (at least at my setup) and fails with the following exception/stacktrace:

Exception in thread "main" java.lang.Error: java.lang.reflect.InvocationTargetException
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.<init>(BGMBuilder.java:147)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:117)
        at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:425)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:174)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
        at org.hisrc.jsonix.JsonixMain.execute(JsonixMain.java:99)
        at org.hisrc.jsonix.JsonixMain.main(JsonixMain.java:77)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:102)
        ... 7 more
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
        at com.sun.tools.xjc.reader.xmlschema.BindingComponent.getClassSelector(BindingComponent.java:65)
        at com.sun.tools.xjc.reader.xmlschema.ColorBinder.<init>(ColorBinder.java:62)
        at com.sun.tools.xjc.reader.xmlschema.BindGreen.<init>(BindGreen.java:63)
        ... 12 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:102)
        ... 15 more
Caused by: java.lang.NoClassDefFoundError: javax/activation/MimeTypeParseException
        at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
        at java.base/java.lang.Class.getConstructor0(Unknown Source)
        at java.base/java.lang.Class.getDeclaredConstructor(Unknown Source)
        at com.sun.tools.xjc.reader.Ring.get(Ring.java:100)
        at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.<init>(DefaultClassBinder.java:98)
        at com.sun.tools.xjc.reader.xmlschema.ClassSelector.<init>(ClassSelector.java:214)
        ... 20 more
Caused by: java.lang.ClassNotFoundException: javax.activation.MimeTypeParseException
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 27 more

I guessed, that Oracle removed again some classes from the standard classpath. Thus, I tried to load the javax.activation-api binary (https://mvnrepository.com/artifact/javax.activation/javax.activation-api/1.2.0) manually into the classpath, which results in another couple of warnings:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/C:/Users/fir3/projects/Test/xml-test/node_modules/jsonix/lib/jsonix-schema-compiler-full.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
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

(This is actually quiet funny because the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector is Oracle...)

I was able to hide those error messages using a property-flag. My final command line command looked like this:

java -Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize -cp node_modules\jsonix\lib\jsonix-schema-compiler-full.jar;javax.activation-api-1.2.0.jar org.hisrc.jsonix.JsonixMain -d src\mappings -p PunnyCake my.xsd

EDIT: I'm using Java 10 and not Java 9.

Activity

  1. changed the title [-]Compiler execution fails using Java 9[/-] [+]Compiler execution fails using Java 10[/+] on Sep 9, 2019
  2. develmusa commented on Dec 9, 2019

    @develmusa

    After testing different openjdk versions, I can confirm the problem.
    OpenJDK Java 8 => No Exception
    OpenJDK Java 10/11/13 => Exception

  3. kelaicai commented on Sep 10, 2020

    @kelaicai

    how can i use it in java?

  4. kallmekunal commented on Jan 25, 2023

    @kallmekunal

    I am still facing this issue in java11.
    Any resolution suggested?

  5. grifhammer commented on May 19, 2023

    @grifhammer

    @kallmekunal you can install openjdk 8 and run this as a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions