1

We are usung Wildfly 10.0.1 and going to switch to jdk17 LTS. I've just installed a new jdk on my mac and downloaded clean version of Wildfly 10.0.1 (no deployments, no config changes and so on). When I am trying to run Wildfly (./standalone.sh), I am getting the following error:

./standalone.sh
   WARNING:  JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.
             JBOSS_HOME: /opt/wildfly_clean
=========================================================================
  JBoss Bootstrap Environment
  JBOSS_HOME: /opt/wildfly_clean
  JAVA: /Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home/bin/java
  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
=========================================================================

Exception in thread "main" javax.xml.stream.FactoryConfigurationError: Provider com.sun.xml.internal.stream.XMLInputFactoryImpl could not be instantiated: java.lang.reflect.InvocationTargetException
    at java.xml/javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:201)
    at java.xml/javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:148)
    at java.xml/javax.xml.stream.FactoryFinder.find(FactoryFinder.java:326)
    at java.xml/javax.xml.stream.FactoryFinder.find(FactoryFinder.java:223)
    at java.xml/javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:166)
    at __redirected.__XMLInputFactory.<clinit>(__XMLInputFactory.java:66)
    at __redirected.__JAXPRedirected.initAll(__JAXPRedirected.java:77)
    at org.jboss.modules.Module$1.run(Module.java:132)
    at org.jboss.modules.Module$1.run(Module.java:119)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
    at org.jboss.modules.Module.<clinit>(Module.java:119)
    at org.jboss.modules.Main.main(Main.java:385)
Caused by: java.lang.reflect.InvocationTargetException
    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 java.xml/javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:190)
    ... 11 more
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider __redirected.__SAXParserFactory could not be instantiated: java.lang.reflect.InvocationTargetException
    at java.xml/javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:199)
    at java.xml/javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:147)
    at java.xml/javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:227)
    at java.xml/javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:181)
    at java.xml/jdk.xml.internal.JdkXmlUtils.getSAXFactory(JdkXmlUtils.java:352)
    at java.xml/jdk.xml.internal.JdkXmlUtils.<clinit>(JdkXmlUtils.java:89)
    at java.xml/com.sun.org.apache.xerces.internal.impl.PropertyManager.initConfigurableReaderProperties(PropertyManager.java:144)
    at java.xml/com.sun.org.apache.xerces.internal.impl.PropertyManager.<init>(PropertyManager.java:78)
    at java.xml/com.sun.xml.internal.stream.XMLInputFactoryImpl.<init>(XMLInputFactoryImpl.java:51)
    ... 17 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(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 java.xml/javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:188)
    ... 25 more
Caused by: java.lang.IllegalAccessError: class __redirected.__SAXParserFactory cannot access class com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl (in module java.xml) because module java.xml does not export com.sun.org.apache.xerces.internal.jaxp to unnamed module @2b05039f
    at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392)
    at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:489)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at __redirected.__SAXParserFactory.<init>(__SAXParserFactory.java:106)
    ... 31 more

There is not much information about it in inet. So, my question is what does that error means and is it possible to do commething (change JAVA_OPTS etc) to run wildfly successfully on jdk 17.

Is it possible at all to run Wildfly 10 on jdk17?

Thank you.

cringe
  • 13,401
  • 15
  • 69
  • 102
EasyRider
  • 149
  • 2
  • 9
  • Temporary workaround: try to add `--add-opens java.xml/com.sun.org.apache.xerces.internal.jaxp=ALL-UNNAMED` to JAVA_OPTS – Stefan Zobel Nov 27 '21 at 17:34

2 Answers2

4

Try using the following configuration

  --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED

Which opens this module for external acess.

Reason for that is

According to JDK9 doc

Some tools and libraries use reflection to access parts of the JDK that are meant for internal use only. This illegal reflective access will be disabled in a future release of the JDK. In JDK 9, it is permitted by default and a warning is issued.

This has changed though with JEP 396 which was included in JDK 17 and was originaly delivered from JDK 16

https://openjdk.java.net/jeps/396

So from JDK 16 and onwards all java internals are by default strongly encapsulated, and no external access is allowed from reflection. Therefore the error you see

Panagiotis Bougioukos
  • 15,955
  • 2
  • 30
  • 47
2

Thank you guys for directions to look at. I was able to run Wildfly 10 in jdk 17 LTS adding the following options to starting shell script:

JAVA_OPTS="$JAVA_OPTS --add-opens java.xml/com.sun.org.apache.xerces.internal.jaxp=ALL-UNNAMED"

JAVA_OPTS="$JAVA_OPTS --add-opens java.base/java.lang=ALL-UNNAMED"

JAVA_OPTS="$JAVA_OPTS --add-opens=java.base/java.security=ALL-UNNAMED"

Here is the output from running script:

./standalone.sh

WARNING: JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.

         JBOSS_HOME: /opt/wildfly_clean

=========================================================================

JBoss Bootstrap Environment

JBOSS_HOME: /opt/wildfly_clean

JAVA: /Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home/bin/java

JAVA_OPTS: -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true --add-opens java.xml/com.sun.org.apache.xerces.internal.jaxp=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED

=========================================================================

...... 10:34:36,425 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 1339ms - Started 331 of 577 services (393 services are lazy, passive or on-demand)

EasyRider
  • 149
  • 2
  • 9
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 29 '21 at 19:46