简体   繁体   中英

cannot access class org.jcp.xml.dsig.internal.dom.XMLDSigRI (in module java.xml.crypto)

we are using XMLSignatureFactory to get instance like below. which was working fine in JDK 12 but now when upgrading to JDK17 giving below error in runtime. Any one please can provide input.

String providerName = System.getProperty("jsr105Provider", "org.jcp.xml.dsig.internal.dom.XMLDSigRI");
        try {
            return XMLSignatureFactory.getInstance("DOM", (Provider) Class.forName(providerName).newInstance());

}.......

Caused by: java.lang.IllegalAccessException: class com.test.OutboundMessageHandlerImpl cannot access class org.jcp.xml.dsig.internal.dom.XMLDSigRI (in module java.xml.crypto) because module java.xml.crypto does not export org.jcp.xml.dsig.internal.dom to unnamed module @6580cfdd

Java 17 is stricter with reflections/introspection.

As a quick-fix you can add --add-opens java.xml.crypto/org.jcp.xml.dsig.internal.dom=ALL-UNNAMED as vm options when running the application. But you should upgrade the package to a version which is java 17 compatible if possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM