dieter
dieter

Reputation: 55

Parsing Hazelcast 4.1 XmlClientConfig fails in Apache TomEE

Trying to construct a Hazelcast 4.1 client configuration from XML throws IllegalArgumentException if the application is running in Apache TomEE-Plus 8.0.0.

If executed in a standalone Java VM (AdoptOpenJDK 11.0.5), the problem does not occur.

Standalone test and TomEE use identical JDK.

Part of the stack trace:

java.lang.IllegalArgumentException: Nicht unterstützt: http://javax.xml.XMLConstants/property/accessExternalDTD
    at org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:571)
    at com.hazelcast.config.AbstractXmlConfigHelper.schemaValidation(AbstractXmlConfigHelper.java:109)
    at com.hazelcast.client.config.XmlClientConfigBuilder.parseAndBuildConfig(XmlClientConfigBuilder.java:175)
    at com.hazelcast.client.config.XmlClientConfigBuilder.build(XmlClientConfigBuilder.java:157)
    at com.hazelcast.client.config.XmlClientConfigBuilder.build(XmlClientConfigBuilder.java:150)
    at com.hazelcast.client.config.XmlClientConfigBuilder.build(XmlClientConfigBuilder.java:145)
    ...

I found a post on StackOverflow that seems to be related to my problem: Set feature accessExternalDTD in TransformerFactory Unfortunately, I have no idea if the suggested solution in answer no. 1 really matches my problem. And even if so, I do not know how to apply the suggested solution in application code or configurations only, without changes inside Hazelcast code.

Any ideas how to fix this?

Hazelcast Client-Config XML:

<?xml version="1.0" encoding="UTF-8"?>
<hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-4.1.xsd"
                  xmlns="http://www.hazelcast.com/schema/client-config"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    ...
 
</hazelcast-client>

TomEE version:

apache-tomee-plus-8.0.0 (Apache Tomcat Version 9.0.22)

Java version:

AdoptOpenJDK 11.0.5
IMPLEMENTOR="AdoptOpenJDK"
IMPLEMENTOR_VERSION="AdoptOpenJDK"
JAVA_VERSION="11.0.5"
JAVA_VERSION_DATE="2019-10-15"
MODULES="java.base java.compiler java.datatransfer java.xml java.prefs java.desktop java.instrument java.logging java.management java.security.sasl java.naming java.rmi java.management.rmi java.net.http java.scripting java.security.jgss java.transaction.xa java.sql java.sql.rowset java.xml.crypto java.se java.smartcardio jdk.accessibility jdk.internal.vm.ci jdk.management jdk.unsupported jdk.internal.vm.compiler jdk.aot jdk.charsets jdk.crypto.ec jdk.crypto.cryptoki jdk.dynalink jdk.httpserver jdk.internal.ed jdk.internal.le jdk.internal.vm.compiler.management jdk.jdwp.agent jdk.jfr jdk.jsobject jdk.localedata jdk.management.agent jdk.management.jfr jdk.naming.dns jdk.naming.rmi jdk.net jdk.pack jdk.scripting.nashorn jdk.scripting.nashorn.shell jdk.sctp jdk.security.auth jdk.security.jgss jdk.xml.dom jdk.zipfs"
OS_ARCH="x86_64"
OS_NAME="Linux"
SOURCE=".:git:7d14fe4b6f30"

Upvotes: 0

Views: 3839

Answers (4)

Grant Lay
Grant Lay

Reputation: 840

I recently encountered this when running hazelcast 5.3 and having version 5.0.0 of apache poi-ooxml on the classpath. This was bringing in version 2.7.2 of xalan.

Upgrading to 5.3.0 of apache.poi-ooxml fixed the issue for me as judging from the maven dependency tree xalan is no longer being used.

Upvotes: 0

Rituraj Sharma
Rituraj Sharma

Reputation: 321

you can exclude the xercesImpl and xalan from esapi dependency.

<dependency>
        <groupId>org.owasp.esapi</groupId>
        <artifactId>esapi</artifactId>
        <version>2.3.0.0</version>
        <exclusions>
            <exclusion>
                <groupId>xerces</groupId>
                <artifactId>xercesImpl</artifactId>
            </exclusion>
            <exclusion>
                <groupId>xalan</groupId>
                <artifactId>xalan</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Upvotes: 0

Vassilis Bekiaris
Vassilis Bekiaris

Reputation: 823

This looks like this issue which is due to the presence of an old JAXP implementation in the classpath. This is fixed in Hazelcast 4.1.1 (fix pull request) by supplying a system property switch to avoid failing when XXE protection cannot be turned on.

You should be able to start your Hazelcast client in Apache TomEE by upgrading to Hazelcast 4.1.1 and setting system property hazelcast.ignoreXxeProtectionFailures=true (for example by supplying -Dhazelcast.ignoreXxeProtectionFailures=true to Apache TomEE's java startup command line).

Upvotes: 2

Riaz
Riaz

Reputation: 89

This seems to be an issue with XML / DTD . Please check with the following config file https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/resources/hazelcast-client-default.xml and code

public ClientConfig clientConfig() throws Exception {
  return new XmlClientConfigBuilder("hazelcast-client.xml").build();
}

Upvotes: 0

Related Questions