kriegaex / Galileo-Openbook-Cleaner

HTML cleaner for Galileo Computing's openbooks, implemented in Java
Other
64 stars 6 forks source link

Fehlermeldung beim Start des openbook Cleaners #38

Closed harrykl closed 2 years ago

harrykl commented 2 years ago

Hallo,

ich bekomme beim Aufruf des Cleaners folgende Fehlermeldung java -jar openbook_cleaner-1.2.0-SNAPSHOT.jar -d . all Exception in thread "main" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at com.simontuffs.onejar.Boot.run(Boot.java:306) at com.simontuffs.onejar.Boot.main(Boot.java:159) Caused by: java.lang.ExceptionInInitializerError at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:820) at com.thoughtworks.xstream.XStream.<init>(XStream.java:574) at com.thoughtworks.xstream.XStream.<init>(XStream.java:496) at com.thoughtworks.xstream.XStream.<init>(XStream.java:465) at com.thoughtworks.xstream.XStream.<init>(XStream.java:411) at com.thoughtworks.xstream.XStream.<init>(XStream.java:378) at de.scrum_master.galileo.Book.<clinit>(Book.java:23) at de.scrum_master.galileo.Options.parse(Options.java:46) at de.scrum_master.galileo.OpenbookCleaner.processArgs(OpenbookCleaner.java:36) at de.scrum_master.galileo.OpenbookCleaner.main_aroundBody0(OpenbookCleaner.java:29) at de.scrum_master.galileo.OpenbookCleaner.main_aroundBody1$advice(OpenbookCleaner.java:12) at de.scrum_master.galileo.OpenbookCleaner.main(OpenbookCleaner.java:1) ... 6 more Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @eec5a4a at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177) at java.base/java.lang.reflect.Field.setAccessible(Field.java:171) at com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:39) at com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:50) ... 18 more

kriegaex commented 2 years ago

This project uses XStream 1.4.8, but even upgrading to XStream 1.4.18 does not completely solve the problem of the library being incompatible with Java 16 and 17. This is well known and due to the fact that Xstream uses internal Java APIs which by default are blocked since the JDK moved on to further restricting deprecated or internal API access. Currently, you have two options:

  1. Build and run on a Java version <16.
  2. Run the cleaner with JVM options --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED in order to help XStream access the APIs it needs.
kriegaex commented 2 years ago

The best I could do for you is upgrade to 1.4.18, after I found out how to avoid an XML parsing error due to certain security-related changes in XStream usage. See commit https://github.com/kriegaex/Galileo-Openbook-Cleaner/commit/5a39042d5ee05f6134c7d380f12b338c23adce4b.

Now, on JDK 16+ you only need to add --add-opens java.base/java.util=ALL-UNNAMED, but XStream still does not work completely without opening that package, unfortunately.

See https://github.com/x-stream/xstream/issues/262.

harrykl commented 2 years ago

This project uses XStream 1.4.8, but even upgrading to XStream 1.4.18 does not completely solve the problem of the library being incompatible with Java 16 and 17. This is well known and due to the fact that Xstream uses internal Java APIs which by default are blocked since the JDK moved on to further restricting deprecated or internal API access. Currently, you have two options:

  1. Build and run on a Java version <16.
  2. Run the cleaner with JVM options --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED in order to help XStream access the APIs it needs.

Thank You. Works for me!!!!