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] Azure Core 1.14.0 incompatible with Spring Boot 2.3/2.4 #19897

Closed
mrm9084 opened this issue Mar 17, 2021 · 6 comments · Fixed by #19918
Closed

[BUG] Azure Core 1.14.0 incompatible with Spring Boot 2.3/2.4 #19897

mrm9084 opened this issue Mar 17, 2021 · 6 comments · Fixed by #19918
Assignees
Labels
Azure.Core azure-core blocking-release Blocks release Client This issue points to a problem in the data-plane of the library. dependency-issue-jackson Issue caused by dependency version mismatch with one of the Jackson libraries
Milestone

Comments

@mrm9084
Copy link
Member

mrm9084 commented Mar 17, 2021

Describe the bug
Using any library that uses Azure Core 1.14.0 results in NoSuchMethodError when using Spring Boot.

Exception or Stack Trace
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.coercionConfigDefaults()Lcom/fasterxml/jackson/databind/cfg/MutableCoercionConfig;
at com.azure.core.util.serializer.JacksonAdapter.(JacksonAdapter.java:106)
at com.azure.core.util.serializer.JacksonAdapter.createDefaultSerializerAdapter(JacksonAdapter.java:139)
at com.azure.core.http.rest.RestProxy.createDefaultSerializer(RestProxy.java:585)
at com.azure.core.http.rest.RestProxy.create(RestProxy.java:637)
at com.azure.data.appconfiguration.ConfigurationAsyncClient.(ConfigurationAsyncClient.java:73)
at com.azure.data.appconfiguration.ConfigurationClientBuilder.buildAsyncClient(ConfigurationClientBuilder.java:205)
at hello.ApplicationRunnerTaskExecutor.run(ApplicationRunnerTaskExecutor.java:48)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:785)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
at hello.Application.main(Application.java:18)
... 6 more

To Reproduce

  1. Create Basic Spring Boot Project using Spring Boot Starter
  2. Include a Azure Library that uses Azure Core 1.14.0 (I am using azure-data-appconfiguration 1.1.10)
  3. Use an then just had the sync and async examples of the library.
  4. Run

Code Snippet

ConfigurationAsyncClient configurationClient = new ConfigurationClientBuilder()
            .connectionString("my-connectionString")
            .buildAsyncClient();

        SettingSelector settingSelector = new SettingSelector().setKeyFilter("*")
            .setLabelFilter("*");

        configurationClient.listRevisions(settingSelector).byPage(1);

        ConfigurationClient configurationClientSync = new ConfigurationClientBuilder()
            .connectionString(
                "my-connection-string")
            .buildClient();

        settingSelector = new SettingSelector().setKeyFilter("*")
            .setLabelFilter("*");

        System.out.println("Pre Request");
        Iterator<PagedResponse<ConfigurationSetting>> iter = configurationClientSync.listRevisions(settingSelector)
            .iterableByPage().iterator();

        System.out.println("Getting Next Page");
        PagedResponse<ConfigurationSetting> response = iter.next();

Expected behavior
They should be compatible as azure-sdk-for-java has spring boot libraries in it.

Setup (please complete the following information):

  • OS: Windows 10
  • IDE : Eclipse
  • azure-data-appconfiguration 1.1.10, spring-boot-starter 2.3.9/2.4.1

Additional context
I was able to get it to work by overriding the Jackson libraries in my pom file, but not sure what side affects this may have, and shouldn't be required.

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

  • [x ] Bug Description Added
  • [x ] Repro Steps Added
  • [x ] 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 Mar 17, 2021
@joshfree joshfree added Azure.Core azure-core Client This issue points to a problem in the data-plane of the library. labels Mar 17, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Mar 17, 2021
@joshfree joshfree added this to the [2021] April milestone Mar 17, 2021
@joshfree
Copy link
Member

@alzimmermsft PTAL

@saragluna
Copy link
Member

@alzimmermsft

This could be an issue or pain point for the Spring users, @stliu suggested that we do some check in the JacksonAdapter to see whether Jackson 2.12 is on the classpath. And if so, we could then call this reflectively:

this.xmlMapper.coercionConfigDefaults()
            .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsNull);

In this case, we'll not break the Spring users, and make sure the azure-core could work with both Jackson 2.12 and 2.11.

Does this approach make sense to you?

@saragluna
Copy link
Member

saragluna commented Mar 17, 2021

@mrm9084

It's caused by a diverge of Jackson's version between azure-core and Spring bom. There's a workaround for this to add this property to your pom.xml:

<properties>
  <jackson-bom.version>2.12.1</jackson-bom.version>
</properties>

In the meantime, we'll work with @alzimmermsft to see whether do we have a better approach here.

@g2vinay g2vinay added the blocking-release Blocks release label Mar 17, 2021
@alzimmermsft
Copy link
Member

@saragluna, yes, using reflective access makes sense to me for not introducing a breaking change. I'll look into this shortly.

@mrm9084
Copy link
Member Author

mrm9084 commented Mar 18, 2021

Seems to have fixed part of this issue but I am still seeing an error.

2021-03-18 14:29:39.025  INFO 32952 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
[WARNING] 
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:578)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.coercionConfigDefaults()Lcom/fasterxml/jackson/databind/cfg/MutableCoercionConfig;
	at com.azure.core.util.serializer.JacksonAdapter.<init>(JacksonAdapter.java:106)
	at com.azure.core.util.serializer.JacksonAdapter.createDefaultSerializerAdapter(JacksonAdapter.java:139)
	at com.azure.core.http.rest.RestProxy.createDefaultSerializer(RestProxy.java:585)
	at com.azure.core.http.rest.RestProxy.create(RestProxy.java:637)
	at com.azure.data.appconfiguration.ConfigurationAsyncClient.<init>(ConfigurationAsyncClient.java:73)
	at com.azure.data.appconfiguration.ConfigurationClientBuilder.buildAsyncClient(ConfigurationClientBuilder.java:205)
	at hello.ApplicationRunnerTaskExecutor.run(ApplicationRunnerTaskExecutor.java:41)
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
	at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:785)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
	at hello.Application.main(Application.java:18)
	... 6 more

@mrm9084 mrm9084 reopened this Mar 18, 2021
@mrm9084
Copy link
Member Author

mrm9084 commented Mar 18, 2021

Needed to update to beta version in app config repo to see update.

@mrm9084 mrm9084 closed this as completed Mar 18, 2021
@alzimmermsft alzimmermsft added the dependency-issue-jackson Issue caused by dependency version mismatch with one of the Jackson libraries label Oct 6, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core azure-core blocking-release Blocks release Client This issue points to a problem in the data-plane of the library. dependency-issue-jackson Issue caused by dependency version mismatch with one of the Jackson libraries
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants