Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.34k stars 1.98k forks source link

java.lang.VerifyError: Bad return type while building ClientSecretCredential #22028

Closed mas9002 closed 3 years ago

mas9002 commented 3 years ago

Describe the bug Getting java.lang.VerifyError: Bad return type while building ClientSecretCredential to get graphClient inorder to read emails from the exchange server.

Exception or Stack Trace

java.lang.VerifyError: Bad return type
  Exception Details:
  Location:
    com/fasterxml/jackson/databind/cfg/MapperBuilder.streamFactory()Lcom/fasterxml/jackson/core/TokenStreamFactory; @7: areturn
  Reason:
    Type 'com/fasterxml/jackson/core/JsonFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/TokenStreamFactory' (from method signature)
  Current Frame:
    bci: @7
    flags: { }
    locals: { 'com/fasterxml/jackson/databind/cfg/MapperBuilder' }
    stack: { 'com/fasterxml/jackson/core/JsonFactory' }
  Bytecode:
    0000000: 2ab4 0002 b600 08b0                    

        at com.fasterxml.jackson.databind.json.JsonMapper.builder(JsonMapper.java:114) ~[jackson-databind-2.12.3.jar:2.12.3]
        at com.azure.core.util.serializer.JacksonAdapter.<init>(JacksonAdapter.java:130) ~[azure-core-1.16.0.jar:na]
        at com.azure.core.util.serializer.JacksonAdapter.createDefaultSerializerAdapter(JacksonAdapter.java:189) ~[azure-core-1.16.0.jar:na]
        at com.azure.identity.implementation.IdentityClient.<clinit>(IdentityClient.java:96) ~[azure-identity-1.3.0.jar:na]
        at com.azure.identity.implementation.IdentityClientBuilder.build(IdentityClientBuilder.java:113) ~[azure-identity-1.3.0.jar:na]
        at com.azure.identity.ClientSecretCredential.<init>(ClientSecretCredential.java:50) ~[azure-identity-1.3.0.jar:na]
        at com.azure.identity.ClientSecretCredentialBuilder.build(ClientSecretCredentialBuilder.java:76) ~[azure-identity-1.3.0.jar:na]
        at com.oracle.corparch.mna.catcore.emailops.EmailOpsExchange.ensureGraphClient(EmailOpsExchange.java:42) ~[classes/:na]
        at com.oracle.corparch.mna.parser.emailreader.EmailScheduledReader.readAndParseBatch(EmailScheduledReader.java:48) ~[classes/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
        at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
        at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[na:na]
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

Dependencies used

com.fasterxml.jackson.core jackson-core 2.12.3
    <dependency>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>msal4j</artifactId>
        <version>1.10.0</version>
    </dependency> 
    <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-identity</artifactId>
        <version>1.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.microsoft.graph</groupId>
        <artifactId>microsoft-graph</artifactId>
        <version>3.7.0</version>
    </dependency>`

Maven Tree `[INFO] +- org.apache.commons:commons-lang3:jar:3.4:compile [INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.2.1.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:2.2.1.RELEASE:compile [INFO] | | - org.aspectj:aspectjweaver:jar:1.9.4:compile [INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.2.1.RELEASE:compile [INFO] | | - org.springframework:spring-jdbc:jar:5.2.1.RELEASE:compile [INFO] | +- jakarta.activation:jakarta.activation-api:jar:1.2.1:compile [INFO] | +- jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile [INFO] | +- jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile [INFO] | +- org.hibernate:hibernate-core:jar:5.4.8.Final:compile [INFO] | | +- org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile [INFO] | | +- org.javassist:javassist:jar:3.24.0-GA:compile [INFO] | | +- antlr:antlr:jar:2.7.7:compile [INFO] | | +- org.jboss:jandex:jar:2.0.5.Final:compile [INFO] | | +- com.fasterxml:classmate:jar:1.5.1:compile [INFO] | | +- org.dom4j:dom4j:jar:2.1.1:compile [INFO] | | +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.0.Final:compile [INFO] | | - org.glassfish.jaxb:jaxb-runtime:jar:2.3.2:compile [INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.2:compile [INFO] | | +- com.sun.istack:istack-commons-runtime:jar:3.0.8:compile [INFO] | | +- org.jvnet.staxex:stax-ex:jar:1.8.1:compile [INFO] | | - com.sun.xml.fastinfoset:FastInfoset:jar:1.2.16:compile [INFO] | +- org.springframework.data:spring-data-jpa:jar:2.2.1.RELEASE:compile [INFO] | | +- org.springframework.data:spring-data-commons:jar:2.2.1.RELEASE:compile [INFO] | | +- org.springframework:spring-orm:jar:5.2.1.RELEASE:compile [INFO] | | +- org.springframework:spring-context:jar:5.2.1.RELEASE:compile [INFO] | | +- org.springframework:spring-tx:jar:5.2.1.RELEASE:compile [INFO] | | +- org.springframework:spring-beans:jar:5.2.1.RELEASE:compile [INFO] | | - org.slf4j:slf4j-api:jar:1.7.29:compile [INFO] | - org.springframework:spring-aspects:jar:5.2.1.RELEASE:compile [INFO] +- com.oracle.corparch.mna:catcore:jar:202011-1:compile [INFO] | +- com.oracle.oci.sdk:oci-java-sdk-core:jar:1.19.3:compile [INFO] | | +- com.oracle.oci.sdk:oci-java-sdk-common:jar:1.19.3:compile [INFO] | | | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile [INFO] | | | +- org.glassfish.jersey.core:jersey-client:jar:2.29.1:compile [INFO] | | | | +- jakarta.ws.rs:jakarta.ws.rs-api:jar:2.1.6:compile [INFO] | | | | +- org.glassfish.jersey.core:jersey-common:jar:2.29.1:compile [INFO] | | | | | +- org.glassfish.hk2:osgi-resource-locator:jar:1.0.3:compile [INFO] | | | | | - com.sun.activation:jakarta.activation:jar:1.2.1:compile [INFO] | | | | - org.glassfish.hk2.external:jakarta.inject:jar:2.6.1:compile [INFO] | | | +- org.glassfish.jersey.inject:jersey-hk2:jar:2.29.1:compile [INFO] | | | | - org.glassfish.hk2:hk2-locator:jar:2.6.1:compile [INFO] | | | | +- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.6.1:compile [INFO] | | | | +- org.glassfish.hk2:hk2-api:jar:2.6.1:compile [INFO] | | | | - org.glassfish.hk2:hk2-utils:jar:2.6.1:compile [INFO] | | | +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.29.1:compile [INFO] | | | | +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.29.1:compile [INFO] | | | | - com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.10.0:compile [INFO] | | | +- org.bouncycastle:bcpkix-jdk15on:jar:1.60:compile [INFO] | | | +- org.bouncycastle:bcprov-jdk15on:jar:1.60:compile [INFO] | | | +- com.nimbusds:nimbus-jose-jwt:jar:8.5:compile [INFO] | | | +- io.github.resilience4j:resilience4j-circuitbreaker:jar:1.2.0:compile [INFO] | | | | +- io.vavr:vavr:jar:0.10.0:compile [INFO] | | | | | - io.vavr:vavr-match:jar:0.10.0:compile [INFO] | | | | - io.github.resilience4j:resilience4j-core:jar:1.2.0:compile [INFO] | | | - com.oracle.oci.sdk:oci-java-sdk-circuitbreaker:jar:1.19.3:compile [INFO] | | +- com.oracle.oci.sdk:oci-java-sdk-workrequests:jar:1.19.3:compile [INFO] | | +- javax.ws.rs:javax.ws.rs-api:jar:2.1:compile [INFO] | | - javax.validation:validation-api:jar:2.0.1.Final:compile [INFO] | +- org.jsoup:jsoup:jar:1.11.3:compile [INFO] | +- com.oracle:ojdbc8:jar:18.3.0.0:compile [INFO] | +- com.oracle:oraclepki:jar:18.3.0.0:compile [INFO] | +- com.oracle:osdt_cert:jar:18.3.0.0:compile [INFO] | +- com.oracle:osdt_core:jar:18.3.0.0:compile [INFO] | +- com.zaxxer:HikariCP:jar:3.4.1:compile [INFO] | +- com.microsoft.azure:msal4j:jar:1.10.0:compile [INFO] | | - com.nimbusds:oauth2-oidc-sdk:jar:9.4:compile [INFO] | | +- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile [INFO] | | +- com.nimbusds:content-type:jar:2.1:compile [INFO] | | - com.nimbusds:lang-tag:jar:1.5:compile [INFO] | +- com.azure:azure-identity:jar:1.3.0:compile [INFO] | | +- com.azure:azure-core:jar:1.16.0:compile [INFO] | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.10.0:compile [INFO] | | | | +- org.codehaus.woodstox:stax2-api:jar:4.2:compile [INFO] | | | | - com.fasterxml.woodstox:woodstox-core:jar:6.0.1:compile [INFO] | | | +- io.projectreactor:reactor-core:jar:3.3.0.RELEASE:compile [INFO] | | | | - org.reactivestreams:reactive-streams:jar:1.0.3:compile [INFO] | | | - io.netty:netty-tcnative-boringssl-static:jar:2.0.26.Final:compile [INFO] | | +- com.azure:azure-core-http-netty:jar:1.9.2:compile [INFO] | | | +- io.netty:netty-handler:jar:4.1.43.Final:compile [INFO] | | | | +- io.netty:netty-common:jar:4.1.43.Final:compile [INFO] | | | | +- io.netty:netty-transport:jar:4.1.43.Final:compile [INFO] | | | | | - io.netty:netty-resolver:jar:4.1.43.Final:compile [INFO] | | | | - io.netty:netty-codec:jar:4.1.43.Final:compile [INFO] | | | +- io.netty:netty-handler-proxy:jar:4.1.43.Final:compile [INFO] | | | | - io.netty:netty-codec-socks:jar:4.1.43.Final:compile [INFO] | | | +- io.netty:netty-buffer:jar:4.1.43.Final:compile [INFO] | | | +- io.netty:netty-codec-http:jar:4.1.43.Final:compile [INFO] | | | +- io.netty:netty-codec-http2:jar:4.1.43.Final:compile [INFO] | | | +- io.netty:netty-transport-native-unix-common:jar:4.1.43.Final:compile [INFO] | | | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.43.Final:compile [INFO] | | | +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.43.Final:compile [INFO] | | | - io.projectreactor.netty:reactor-netty:jar:0.9.1.RELEASE:compile [INFO] | | +- com.microsoft.azure:msal4j-persistence-extension:jar:1.1.0:compile [INFO] | | | - net.java.dev.jna:jna:jar:4.5.2:compile [INFO] | | +- net.java.dev.jna:jna-platform:jar:4.5.2:compile [INFO] | | - org.linguafranca.pwdb:KeePassJava2:jar:2.1.4:compile [INFO] | | +- org.linguafranca.pwdb:KeePassJava2-kdb:jar:2.1.4:compile [INFO] | | | +- org.linguafranca.pwdb:database:jar:2.1.4:compile [INFO] | | | | - com.madgag.spongycastle:core:jar:1.54.0.0:compile [INFO] | | | - org.jetbrains:annotations:jar:15.0:compile [INFO] | | +- org.linguafranca.pwdb:KeePassJava2-dom:jar:2.1.4:compile [INFO] | | | - org.linguafranca.pwdb:KeePassJava2-kdbx:jar:2.1.4:compile [INFO] | | +- org.linguafranca.pwdb:KeePassJava2-jaxb:jar:2.1.4:compile [INFO] | | - org.linguafranca.pwdb:KeePassJava2-simple:jar:2.1.4:compile [INFO] | | +- org.simpleframework:simple-xml:jar:2.7.1:compile [INFO] | | | +- stax:stax-api:jar:1.0.1:compile [INFO] | | | +- stax:stax:jar:1.2.0:compile [INFO] | | | - xpp3:xpp3:jar:1.1.3.3:compile [INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.12:compile [INFO] | | - com.fasterxml:aalto-xml:jar:1.0.0:compile [INFO] | - com.microsoft.graph:microsoft-graph:jar:3.7.0:compile [INFO] | +- com.google.code.gson:gson:jar:2.8.6:compile [INFO] | +- com.microsoft.graph:microsoft-graph-core:jar:2.0.3:compile [INFO] | +- com.google.guava:guava:jar:30.1.1-jre:compile [INFO] | | +- com.google.guava:failureaccess:jar:1.0.1:compile [INFO] | | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile [INFO] | | +- org.checkerframework:checker-qual:jar:3.8.0:compile [INFO] | | +- com.google.errorprone:error_prone_annotations:jar:2.5.1:compile [INFO] | | - com.google.j2objc:j2objc-annotations:jar:1.3:compile [INFO] | - com.squareup.okhttp3:okhttp:jar:3.14.4:compile [INFO] | - com.squareup.okio:okio:jar:1.17.2:compile [INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.12.3:compile [INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.12.3:compile [INFO] | - com.fasterxml.jackson.core:jackson-annotations:jar:2.10.0:compile [INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.2.1.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.2.1.RELEASE:compile [INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.2.1.RELEASE:compile [INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile [INFO] | | | | - ch.qos.logback:logback-core:jar:1.2.3:compile [INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.12.1:compile [INFO] | | | | - org.apache.logging.log4j:log4j-api:jar:2.12.1:compile [INFO] | | | - org.slf4j:jul-to-slf4j:jar:1.7.29:compile [INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile [INFO] | | - org.yaml:snakeyaml:jar:1.25:runtime [INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.2.1.RELEASE:compile [INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.10.0:compile [INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.10.0:compile [INFO] | | - com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.10.0:compile [INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.2.1.RELEASE:compile [INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.27:compile [INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.27:compile [INFO] | | - org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.27:compile [INFO] | +- org.springframework.boot:spring-boot-starter-validation:jar:2.2.1.RELEASE:compile [INFO] | | +- jakarta.validation:jakarta.validation-api:jar:2.0.1:compile [INFO] | | - org.hibernate.validator:hibernate-validator:jar:6.0.18.Final:compile [INFO] | +- org.springframework:spring-web:jar:5.2.1.RELEASE:compile [INFO] | - org.springframework:spring-webmvc:jar:5.2.1.RELEASE:compile [INFO] | - org.springframework:spring-expression:jar:5.2.1.RELEASE:compile [INFO] +- javax.servlet:servlet-api:jar:2.5:compile [INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.2.1.RELEASE:compile [INFO] | +- org.springframework:spring-aop:jar:5.2.1.RELEASE:compile [INFO] | +- org.springframework.security:spring-security-config:jar:5.2.1.RELEASE:compile [INFO] | | - org.springframework.security:spring-security-core:jar:5.2.1.RELEASE:compile [INFO] | - org.springframework.security:spring-security-web:jar:5.2.1.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-devtools:jar:2.2.1.RELEASE:runtime (optional) [INFO] | +- org.springframework.boot:spring-boot:jar:2.2.1.RELEASE:compile [INFO] | - org.springframework.boot:spring-boot-autoconfigure:jar:2.2.1.RELEASE:compile [INFO] +- org.springframework.boot:spring-boot-configuration-processor:jar:2.2.1.RELEASE:compile (optional) [INFO] +- com.auth0:java-jwt:jar:3.10.3:compile [INFO] | - commons-codec:commons-codec:jar:1.13:compile [INFO] +- org.projectlombok:lombok:jar:1.18.10:compile (optional) [INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.2.1.RELEASE:test [INFO] | +- org.springframework.boot:spring-boot-test:jar:2.2.1.RELEASE:test [INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.2.1.RELEASE:test [INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test [INFO] | | - net.minidev:json-smart:jar:2.3:compile [INFO] | | - net.minidev:accessors-smart:jar:1.2:compile [INFO] | | - org.ow2.asm:asm:jar:5.0.4:compile [INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile [INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.5.2:test [INFO] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.5.2:test [INFO] | | | +- org.apiguardian:apiguardian-api:jar:1.1.0:test [INFO] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test [INFO] | | | - org.junit.platform:junit-platform-commons:jar:1.5.2:test [INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.5.2:test [INFO] | | - org.junit.jupiter:junit-jupiter-engine:jar:5.5.2:test [INFO] | | - org.junit.platform:junit-platform-engine:jar:1.5.2:test [INFO] | +- org.mockito:mockito-junit-jupiter:jar:3.1.0:test [INFO] | +- org.assertj:assertj-core:jar:3.13.2:test [INFO] | +- org.hamcrest:hamcrest:jar:2.1:compile [INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test [INFO] | | - com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test [INFO] | +- org.springframework:spring-core:jar:5.2.1.RELEASE:compile [INFO] | | - org.springframework:spring-jcl:jar:5.2.1.RELEASE:compile [INFO] | +- org.springframework:spring-test:jar:5.2.1.RELEASE:test [INFO] | - org.xmlunit:xmlunit-core:jar:2.6.3:test [INFO] +- org.json:json:jar:20180130:compile [INFO] +- org.mockito:mockito-core:jar:3.0.0:test [INFO] | +- net.bytebuddy:byte-buddy:jar:1.10.2:compile [INFO] | +- net.bytebuddy:byte-buddy-agent:jar:1.10.2:test [INFO] | - org.objenesis:objenesis:jar:2.6:test [INFO] - commons-io:commons-io:jar:2.6:compile

Code

public void ensureGraphClient() {
        ConfidentialClientApplication app;
/*ISSUE IS IN THE BELOW CODE WHILE BUILDING clientSecretCredential*/
        final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
                .clientId("client_id").clientSecret("client_secret")
                .tenantId("tenant_id").build();

        final TokenCredentialAuthProvider tokenCredAuthProvider = new TokenCredentialAuthProvider(
                Arrays.asList("Mail.Read"), clientSecretCredential);

        graphClient = GraphServiceClient.builder().authenticationProvider(tokenCredAuthProvider).buildClient();
    }

JAVA VERSION java version "11.0.8" 2020-07-14 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.8+10-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode)

SETUP OS:macOS Mojave Version 10.14.6 IDE: Visual Studio Code

mas9002 commented 3 years ago

found a similar issue: https://github.com/Azure/azure-sdk-for-java/issues/20428

alzimmermsft commented 3 years ago

Thank you for submitting this issue @mas9002. Either @g2vinay or myself will get back to you soon.

alzimmermsft commented 3 years ago

Hi @mas9002, I see that a Spring Boot library with version 2.2.x is being used in your application. This is leading to Jackson, and Netty, libraries resolving to different versions than expected as dependencies by both azure-identity and microsoft-graph. The latest versions of Azure SDKs for Java in the com.azure groupId use dependencies compatible with Spring 2.4.x.

Is it possible to upgrade to Spring 2.4.x? If not, is it possible to include jackson-bom 2.12.3 and netty-bom 4.1.63 as dependencyManagement dependencies? Both of these solutions should resolve this exception.

mas9002 commented 3 years ago

Thanks @alzimmermsft works with the version bump.