S
By Suhas Das
Author
8 views
Exception in thread "main" java.lang.IllegalAccessError: class xxxx (in unnamed module @0x2362f559) cannot access class com.sun.org.apache.xerces.internal.parsers.DOMParser (in module java.xml) because module java.xml does not export com.sun.org.apache.xerces.internal.parsers to unnamed module @0x2362f559
solution:
Real solutions (choose one)
1. Stop using internal Xerces classes (recommended)
Replace:
com.sun.org.apache.xerces.internal.parsers.DOMParser
with a supported parser such as:
javax.xml.parsers.DocumentBuilderFactory
org.w3c.dom
org.apache.xerces.parsers.DOMParser (external Xerces JAR)
This is the correct long‑term fix.
2. Add JVM flags to open the internal package (works but not ideal)
If you must keep the old code, run Java with:
Code
--add-exports java.xml/com.sun.org.apache.xerces.internal.parsers=ALL-UNNAMED
If you also use other internal Xerces classes, you may need:
Code
--add-exports java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED
--add-exports java.xml/com.sun.org.apache.xerces.internal.jaxp=ALL-UNNAMED
This forces Java to expose the internal package to your unnamed module.