Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Adding Service Bus library changes default Spring Boot behavior #30244

Closed
3 tasks
conniey opened this issue Aug 2, 2022 · 3 comments
Closed
3 tasks

[BUG] Adding Service Bus library changes default Spring Boot behavior #30244

conniey opened this issue Aug 2, 2022 · 3 comments
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. Service Bus

Comments

@conniey
Copy link
Member

conniey commented Aug 2, 2022

Describe the bug

Original: Azure/azure-service-bus-java#416

I am currently using Spring Boot version 2.1.3.RELEASE with version 7.1.0 of Azure service bus.
implementation group: 'com.azure', name: 'azure-messaging-servicebus', version: '7.1.0'. Simply adding the line above to my build.gradle script alters default Spring Boot behavior. Hitting a GET endpoint without any Accept header specified is returning XML instead of JSON and creating a RestTemplate now has a bunch of different Accept types. This is causing existing legacy code to break. It appears to be an issue with all versions of azure-messaging-servicebus after it was moved to the new package.

It appears that the issue is the jackson-dataformat-xml package that comes along with the jar. Excluding this package from the build returns to normal behavior. I am not sure if this is an issue with how you guys are packaging the library or if it is an issue with Spring just automatically consuming it.

Versions
OS platform and version: Mac OSX 10.15.7
Maven package version or commit ID: implementation group: 'com.azure', name: 'azure-messaging-servicebus', version: '7.1.0'

Exception or Stack Trace

DEBUG | 2022-07-22 21:30:44 EDT | ServerVersion = V11.40.7 | ClientVersion = V11.165 | [boundedElastic-2] logging.ClientLogger (ClientLogger.java:491) - Could not find version of 'jackson-dataformat-xml'. | {}

INFO | 2022-07-22 21:30:44 EDT | ServerVersion = V11.40.7 | ClientVersion = V11.165 | [boundedElastic-2] logging.ClientLogger (ClientLogger.java:222) - Package versions: jackson-annotations=2.13.2, jackson-core=2.13.2, jackson-databind=2.13.2.2, jackson-dataformat-xml=unknown, jackson-datatype-jsr310=2.13.2, azure-core=1.29.1, Troubleshooting version conflicts: https://aka.ms/azsdk/java/dependency/troubleshoot | {}

ERROR | 2022-07-22 21:30:44 EDT | ServerVersion = V11.40.7 | ClientVersion = V11.165 | [boundedElastic-2] logging.ClientLogger (ClientLogger.java:506) - Package versions: jackson-annotations=2.13.2, jackson-core=2.13.2, jackson-databind=2.13.2.2, jackson-dataformat-xml=unknown, jackson-datatype-jsr310=2.13.2, azure-core=1.29.1, Troubleshooting version conflicts: https://aka.ms/azsdk/java/dependency/troubleshoot | {}

java.lang.LinkageError: Package versions: jackson-annotations=2.13.2, jackson-core=2.13.2, jackson-databind=2.13.2.2, jackson-dataformat-xml=unknown, jackson-datatype-jsr310=2.13.2, azure-core=1.29.1, Troubleshooting version conflicts: https://aka.ms/azsdk/java/dependency/troubleshoot

at com.azure.core.implementation.jackson.ObjectMapperShim.createHeaderMapper(ObjectMapperShim.java:138) ~[azure-core-1.29.1.jar:1.29.1]
at com.azure.core.util.serializer.JacksonAdapter.<init>(JacksonAdapter.java:81) ~[azure-core-1.29.1.jar:1.29.1]
at com.azure.core.util.serializer.JacksonAdapter.<init>(JacksonAdapter.java:59) ~[azure-core-1.29.1.jar:1.29.1]
at com.azure.core.util.serializer.JacksonAdapter$SerializerAdapterHolder.<clinit>(JacksonAdapter.java:114) ~[azure-core-1.29.1.jar:1.29.1]
at com.azure.core.util.serializer.JacksonAdapter.createDefaultSerializerAdapter(JacksonAdapter.java:123) ~[azure-core-1.29.1.jar:1.29.1]
at com.azure.core.implementation.serializer.DefaultJsonSerializer.<init>(DefaultJsonSerializer.java:27) ~[azure-core-1.29.1.jar:1.29.1]
at com.azure.core.util.serializer.JsonSerializerProviders.createInstance(JsonSerializerProviders.java:57) ~[azure-core-1.29.1.jar:1.29.1]
at com.azure.core.util.BinaryData.<clinit>(BinaryData.java:174) ~[azure-core-1.29.1.jar:1.29.1]
at com.azure.messaging.servicebus.ServiceBusReceivedMessage.getBody(ServiceBusReceivedMessage.java:103) ~[azure-messaging-servicebus-7.8.0.jar:7.8.0]
at i.h.Receiver.processMessage(ASBQueueReceiver.java:142) ~[server-interoperability.jar:?]
at i.h.Receiver.lambda$run$0(ASBQueueReceiver.java:107) ~[server-interoperability.jar:?]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:386) [reactor-core-3.4.17.jar:3.4.17]
at reactor.core.publisher.FluxPublishOn$PublishOnSubscriber.runAsync(FluxPublishOn.java:440) [reactor-core-3.4.17.jar:3.4.17]
at reactor.core.publisher.FluxPublishOn$PublishOnSubscriber.run(FluxPublishOn.java:527) [reactor-core-3.4.17.jar:3.4.17]
at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84) [reactor-core-3.4.17.jar:3.4.17]
at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37) [reactor-core-3.4.17.jar:3.4.17]
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) [?:1.8.0_242]
at java.util.concurrent.FutureTask.run(FutureTask.java) [?:1.8.0_242]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_242]

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_242]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_242]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_242]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]

Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/dataformat/xml/XmlMapper$Builder
at com.azure.core.implementation.jackson.ObjectMapperShim.createHeaderMapper(ObjectMapperShim.java:135) ~[azure-core-1.29.1.jar:1.29.1]

... 22 more

Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.dataformat.xml.XmlMapper$Builder
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1352) ~[catalina.jar:8.0.53]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180) ~[catalina.jar:8.0.53]
at com.azure.core.implementation.jackson.ObjectMapperShim.createHeaderMapper(ObjectMapperShim.java:135) ~[azure-core-1.29.1.jar:1.29.1]

To Reproduce

  1. Create spring boot application.
  2. Add reference to azure-messaging-servicebus

Code Snippet

Expected behavior

Hitting a GET endpoint with no Accept type specified defaults to application/json being returned
Creating a new RestTemplate() defaults the Accept types in the template to [application/json, application/*+json]

Actual Behavior

Hitting a GET endpoint with no Accept type specified defaults to application/xml being returned
Creating a new RestTemplate() defaults the Accept types in the template to [application/xml, text/xml, application/json, application/+xml, application/+json]

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: [e.g. iOS]
  • IDE: [e.g. IntelliJ]
  • Library/Libraries: [e.g. com.azure:azure-core:1.16.0 (groupId:artifactId:version)]
  • Java version: [e.g. 8]
  • App Server/Environment: [e.g. Tomcat, WildFly, Azure Function, Apache Spark, Databricks, IDE plugin or anything special]
  • Frameworks: [e.g. Spring Boot, Micronaut, Quarkus, etc]

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:

  • verbose dependency tree (mvn dependency:tree -Dverbose)
  • exception message, full stack trace, and any available logs

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 2, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 2, 2022
@conniey conniey added Client This issue points to a problem in the data-plane of the library. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Aug 2, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 2, 2022
@joshfree
Copy link
Member

joshfree commented Aug 2, 2022

java.lang.LinkageError: Package versions: jackson-annotations=2.13.2, jackson-core=2.13.2, jackson-databind=2.13.2.2, jackson-dataformat-xml=unknown, jackson-datatype-jsr310=2.13.2, azure-core=1.29.1, Troubleshooting version conflicts: https://aka.ms/azsdk/java/dependency/troubleshoot

Hi @RobOhRob the original issue filed here: Azure/azure-service-bus-java#416, is now being tracked in the centralized Azure SDK for Java repo (here: #30244). @ki1729 from the Service Bus SDK team will follow up with you shortly.

Two quick comments, 1) are you still running 7.1.0? As you can see here https://mvnrepository.com/artifact/com.azure/azure-messaging-servicebus, that version is more than 1 year old and we highly recommend you move to a the latest version for performance, reliability, and security updates.

  1. On the version that you're running on and experiencing this error message, could you please run mvn dependency:tree -Dverbose and share the output? https://aka.ms/azsdk/java/dependency/troubleshoot has more details on how to diagnose and fix common dependency mismatch issues for large projects.

@joshfree
Copy link
Member

joshfree commented Aug 2, 2022

One additional comment, 3) Microsoft recommends that customers reference the azure-sdk-bom BOM file (more information here: Get started with Azure SDK and Apache Maven | Microsoft Docs) for simpler dependency management rather than referencing individual client libraries directly. This will reduce the risk of mismatched dependencies when using multiple client libraries in the same project.

@ki1729
Copy link
Contributor

ki1729 commented Oct 31, 2022

@RobOhRob the problematic jackson xml library has been made an optional dependency. This should fix the issue. Please let us know if that is not the case.

@ki1729 ki1729 closed this as completed Oct 31, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. Service Bus
Projects
None yet
Development

No branches or pull requests

3 participants