Consuming a XML API using Spring WebClient fails if JdkClientHttpConnector
is configured. This exception is thrown:
...
Caused by: java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
...
Attached is a simple project to demonstrate the issue. Please execute Gradle task assemble
to build the JAR file. Then run the application with java -jar ...
. My environment is Eclipse Temurin JDK 21.0.3+9 on Windows 10 22H2 x64.
When running from IntelliJ IDEA directly instead, the issue does not occur.
Not affected are Spring RestClient and RestTemplate when also configured with JDK HttpClient (JdkClientHttpRequestFactory
).
spring-xml-deserializer-bug.zip
Comment From: snicoll
@renetrefft please don't paste things in text like that. It looks like you think a build file is enough to reproduce the issue but it isn't. Also, the fact that it works in your IDE but not on an assembled jar makes it more likely to be a problem in your setup, which we don't have.
Can you edit your description and replace that with an actual sample we can run? You can attach a zip to this issue or push the code to a GitHub repository.
Comment From: renetrefft
@snicoll I have updated my description and attached a demo project.
Comment From: snicoll
@renetrefft thank you for the sample, I can reproduce the problem as you've described. We're investigating.
Comment From: Grixa37
Same problem in AbstractJaxb2HttpMessageConverter
Comment From: bclozel
@Grixa37 plezse open a new issue with a minimal sample.