Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

switching from java 8 to java 11

I have a problem with com.sun.org.apache.xerces.internal.dom#DOMInputImpl() after switch to java 11. in this code:

@Override
public LSInput resolveResource(final String type,
                               final String namespaceURI, final String publicId, String systemId,
                               final String baseURI) {
    final LSInput input = new DOMInputImpl();
    if (systemId.equals(this.systemId)) {
        try {
            input.setByteStream(xsdFile.getInputStream());
        } catch (IOException e) {
            log.error("Error to get classpath resource for schema");
        }
    }
    return input;
}

when compiling I get the error:

Error:(8,42) java: package com.sun.org.apache.xerces.internal.dom is not visible

I tried add to maven-surefire-plugin --add-exports... but it didn't help me

       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven.surefire.plugin.version}</version>
            <configuration>
                <argLine>--illegal-access=permit</argLine>
                <argLine>--add-exports java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED</argLine>
                <argLine>-Dillegal-access=permit</argLine>
            </configuration>
        </plugin>
like image 423
AbrA Avatar asked Jul 18 '26 03:07

AbrA


1 Answers

You should use the original xerces implementation.

The question was also answered here: https://github.com/adoptium/adoptium-support/issues/199#issuecomment-717008260

With JDK 9, the Java Platform Module System was introduced. As part of that, access to internal APIs was shut off that should not have been used in the first place. Resolution: Upgrade your dependencies, stop using internal APIs. In the case of Xerces, the library is available from https://xerces.apache.org/.

like image 140
Anders Lindgren Avatar answered Jul 20 '26 15:07

Anders Lindgren



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!