Some time ago I implemented a CustomCharacterEscapeHandler and it worked fine up-to Wildfly-18.0.1. Now when updating to Wildfly 19 or higher I get the following exception:
javax.xml.bind.PropertyException: property "com.sun.xml.bind.marshaller.CharacterEscapeHandler" must be an instance of type com.sun.xml.bind.marshaller.CharacterEscapeHandler, not my.package.CustomCharacterEscapeHandler
at com.sun.xml.bind.v2.runtime.MarshallerImpl.setProperty(MarshallerImpl.java:489)
But my CustomCharacterEscapeHandler implements exactly the mentioned interface!
The maven pom.xml
looks like this:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.12</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2.11</version>
</dependency>
I researched a lot and did try out all the solutions I could find (1, 2, 3, 4, 5) but many questions remain unanswered (6,7,8,9,10) and the things mentioned did not work. So I tried:
- added jaxb.properties containing
javax.xml.bind.context.factory=com.sun.xml.bind.v2.ContextFactory
- updated to newer JAXB Versions
- added a startup property
-Djavax.xml.bind.context.factory=com.sun.xml.bind.v2.ContextFactory
- added the EscapHandler as inline code
jaxbMarshaller.setProperty(CharacterEscapeHandler.class.getName(), (CharacterEscapeHandler) (chars, start, length, b, writer) -> ... );
- tried adding exclusion(s) in the
jboss-deployment-structure
(com.sun.xml.bind, javax.xml.bind.api,...) and also tried the opposite to add them as dependencies
However nothing worked so far. Any ideas how to fix this?