yccheok / jstock

JStock is a free stock market software for 28 countries.
https://jstock.org
663 stars 347 forks source link

ExceptionInInitializationError: jstock does not start #178

Open MartinKei opened 2 years ago

MartinKei commented 2 years ago

Running on a Fedora 35 with Java 18:

[zombie@localhost jstock]$ java --version
openjdk 18.0.1 2022-04-19
OpenJDK Runtime Environment 22.3 (build 18.0.1+10)
OpenJDK 64-Bit Server VM 22.3 (build 18.0.1+10, mixed mode, sharing)

Results in this error - doesn't matter if running through jstock.sh or with java -jar:

[zombie@localhost jstock]$ java -jar jstock.jar
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:990)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:593)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:515)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:484)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:430)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:369)
    at org.yccheok.jstock.gui.Utils.getXStream(Utils.java:1785)
    at org.yccheok.jstock.gui.Utils.fromXML(Utils.java:1819)
    at org.yccheok.jstock.gui.JStock.getJStockOptionsViaXML(JStock.java:1803)
    at org.yccheok.jstock.gui.JStock.main(JStock.java:1819)
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 @454e0b0b
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:180)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:174)
    at com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:40)
    at com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:50)
    ... 10 more
Heny67 commented 1 year ago

HI

It doesn't work for me either.

Ubuntumate 22.04.1 LTS (Jammy Jellyfish) 64-bit Kernel: Linux 5.15.0-58-generic x86_64 MATE 1.26.0

n@en-B450-AORUS-PRO:~/Letöltések/Install/jstock$ java --version java 19.0.1 2022-10-18 Java(TM) SE Runtime Environment (build 19.0.1+10-21) Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

en@en-B450-AORUS-PRO:~/Letöltések/Install/jstock$ ./jstock.sh Exception in thread "main" java.lang.ExceptionInInitializerError at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:990) at com.thoughtworks.xstream.XStream.(XStream.java:593) at com.thoughtworks.xstream.XStream.(XStream.java:515) at com.thoughtworks.xstream.XStream.(XStream.java:484) at com.thoughtworks.xstream.XStream.(XStream.java:430) at com.thoughtworks.xstream.XStream.(XStream.java:369) at org.yccheok.jstock.gui.Utils.getXStream(Utils.java:1785) at org.yccheok.jstock.gui.Utils.fromXML(Utils.java:1819) at org.yccheok.jstock.gui.JStock.getJStockOptionsViaXML(JStock.java:1803) at org.yccheok.jstock.gui.JStock.main(JStock.java:1819) 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 @4a499116 at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311) at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:180) at java.base/java.lang.reflect.Field.setAccessible(Field.java:174) at com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:40) at com.thoughtworks.xstream.converters.collections.TreeMapConverter.(TreeMapConverter.java:50) ... 10 more

lhl commented 1 year ago

Sadly, same issue as the OP on Arch Linux:

❯ java --version
openjdk 20.0.1 2023-04-18
OpenJDK Runtime Environment (build 20.0.1+9)
OpenJDK 64-Bit Server VM (build 20.0.1+9, mixed mode, sharing)

❯ java -jar jstock.jar 
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:990)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:593)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:515)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:484)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:430)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:369)
    at org.yccheok.jstock.gui.Utils.getXStream(Utils.java:1785)
    at org.yccheok.jstock.gui.Utils.fromXML(Utils.java:1819)
    at org.yccheok.jstock.gui.JStock.getJStockOptionsViaXML(JStock.java:1803)
    at org.yccheok.jstock.gui.JStock.main(JStock.java:1819)
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 @63be40d8
    at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:181)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:175)
    at com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:40)
    at com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:50)
    ... 10 more
jfbauer432 commented 1 year ago

I found a workaround by directly running a very old version of java

/usr/lib/jvm/java-8-openjdk-amd64/bin/java -version
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (build 1.8.0_362-8u372-ga~us1-0ubuntu1~23.04-b09)
OpenJDK 64-Bit Server VM (build 25.362-b09, mixed mode)

/usr/lib/jvm/java-8-openjdk-amd64/bin/java -jar jstock.jar

works

MalayPalace commented 1 year ago

even works on Java 11 but not beyond that

tried with below version and its working:

openjdk version "11.0.20" 2023-07-18
OpenJDK Runtime Environment (build 11.0.20+8-post-Ubuntu-1ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.20+8-post-Ubuntu-1ubuntu122.04, mixed mode, sharing)

Raised a ticket for supporting latest java version: https://github.com/yccheok/jstock/issues/185