XStream java 17 No converter available

Hello,

I’m migrating my application from java 1.8 to java 17.
I’m using axon 4.6.1

I get this error

com.thoughtworks.xstream.converters.ConversionException: No converter available
---- Debugging information ----
message             : No converter available
type                : com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
converter           : com.thoughtworks.xstream.converters.reflection.SerializableConverter
message[1]          : Unable to make private void com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.readObject(java.io.ObjectInputStream) throws java.lang.ClassNotFoundException,java.io.IOException accessible: module java.xml does not "opens com.sun.org.apache.xerces.internal.jaxp.datatype" to unnamed module @646d64ab
converter[1]        : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
message[2]          : Unable to make field private transient java.math.BigInteger com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.orig_eon accessible: module java.xml does not "opens com.sun.org.apache.xerces.internal.jaxp.datatype" to unnamed module @646d64ab
axon:
  serializer:
    general: jackson
    events: jackson
    messages: jackson
object SecureXStreamSerializer {
    fun xStream(): XStream {
        val xStream = XStream()
        xStream.classLoader = SecureXStreamSerializer::class.java.classLoader
        xStream.allowTypesByWildcard(
            arrayOf(
                "org.axonframework.**",
                "sun.org.apache.xerces.internal.jaxp.**",
            )
        )
        return XStreamSerializer.builder().xStream(xStream).build().xStream
    fun storageEngine(mongoTemplate: MongoTemplate): EventStorageEngine = MongoEventStorageEngine.builder()
        .eventSerializer(
            XStreamSerializer.builder()
                .xStream(SecureXStreamSerializer.xStream())
                .build()
        )
        .snapshotSerializer(
            XStreamSerializer.builder()
                .xStream(SecureXStreamSerializer.xStream())
                .build()
        )
        .mongoTemplate(mongoTemplate).build()

Hi,

The easiest would be to move to Jackson for serialization. While it’s possible to work around reflection issues with XStream if needed. There is some interesting information in this Github issue.