how to resolve loader constraint violation issue when using fasterxml.jackson XmlMapper


I want to use com.fasterxml.jackson.dataformat.xml.XmlMapper to write or read json class from xml file, but met below issues;


Cannot load class javax.xml.namespace.NamespaceContext (

error: loader constraint violation: loader @4becad6f wants to load interface javax.xml.namespace.NamespaceContext. A different interface with the same name was previously loaded by 'bootstrap'. (javax.xml.namespace.NamespaceContext is in module java.xml of loader 'bootstrap'),

classLoader=PluginClassLoader(plugin=PluginDescriptor(name=XXX XXX XXX for Android,, descriptorPath=plugin.xml, path=~/git/assistant-android-gpt-poc/idea-sandbox/plugins/AndroidWizard, version=xxxx package=null, isBundled=false), packagePrefix=null, state=active)


My environment: 

Build #IC-232.10072.27, built on October 11, 2023
Runtime version: 17.0.10+7-b1000.50 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

and dependency defined in build.gradle

implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: '2.17.1'




It seems that javax.xml.namespace.NamespaceContext is already loaded by a bootstrap classloader and your dependency loads it again. I suggest checking what classes your dependency adds to the plugin. If it has a transitive dependency providing this class, try to exclude it with Gradle dependency management: