0

We are migrating to using the Microsoft Graph API from using older auth methods.

Previously in this project the dependency management has been very manual, this included downloading .jars and manually importing them into intelliJ for local development.

Since we need to pull in new dependencies for the Graph API SDK, I took it as a chance to pay off some tech-debt and start going toward more programmatic dependency management.

I was able to get the web-app to run properly, however bringing in the new dependencies

https://mvnrepository.com/artifact/com.microsoft.azure/msal4j https://mvnrepository.com/artifact/com.microsoft.graph/microsoft-graph https://mvnrepository.com/artifact/com.azure/azure-core

did not seem to work fully.

Our build.gradle looks like this

dependencies {
    providedCompile 'com.microsoft.graph:microsoft-graph:5.40.0'
    providedCompile 'com.azure:azure-identity:1.7.0'
    // https://mvnrepository.com/artifact/com.azure/azure-core
    implementation group: 'com.azure', name: 'azure-core', version: '1.34.0'
    // https://mvnrepository.com/artifact/com.microsoft.azure/msal4j
    implementation 'com.microsoft.azure:msal4j:1.13.3'

    providedCompile fileTree(dir: "${webAppDirName}/WEB-INF/lib", excludes: [
            'aspose.pdf.jar',
            'aspose-pdf.jar',
            'async-http-client-2.4.4.jar',
            'commons-beanutils-core.jar',
            'commons-collections.jar',
            'commons-fileupload-1.1.jar',
            'commons-fileupload-1.2.2.jar',
            'commons-io-1.1.jar',
            'commons-io-2.1.jar',
            'commons-lang-2.3.jar',
            'commons-logging.jar',
            'commons-logging-1.0.jar',
            'commons-logging-1.1.1.jar',
            'commons-logging-1.1.3.jar',
            'core-1.5.0.jar',
            'empty.jar',
            'firebase-admin-6.3.0.jar',
            'groovy-all-1.7.5.jar',
            'httpclient-4.1.2.jar',
            'httpclient-4.5.jar',
            'httpcore-4.1.2.jar',
            'httpcore-4.4.1.jar',
            'httpmime-4.1.2.jar',
            'itext-2.0.4.jar',
            'jackson-annotations-2.4.0.jar',
            'jackson-annotations-2.8.0.jar',
            'jackson-core-2.4.0.jar',
            'jackson-databind-2.4.0-rc3.jar',
            'jackson-jaxrs-1.9.2.jar',
            'jackson-xc-1.9.2.jar',
            'jasperreports-5.6.0.jar',
            'jersey-json-1.17.1.jar',
            'jsch-0.1.53.jar',
            'json_simple-1.1.jar',
            'mailapi.jar',
            'netty-all-4.1.23.Final.jar',
            'opentok-server-sdk-2.2.0.jar',
            'opentok-server-sdk-4.2.0.jar',
            'reactive-streams-1.0.2.jar',
            'servlet.jar',
            'soap.jar',
            'twilio-7.1.0-jar-with-dependencies.jar',
            'twilio-java-sdk-3.3.10-jar-with-dependencies.jar',
            'webprovider-1.5.0.jar'
    ],include:'*.jar')

    providedCompile 'org.apache.tomcat:tomcat-catalina:8.5.32'
}

The code in particular that I am running into an issue with is located here

    public MicrosoftEmailClient() {
        ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
            .clientId(CLIENT_ID)
            .clientSecret(CLIENT_SECRET)
            .tenantId(TENANT_ID)
            .build();

    TokenCredentialAuthProvider tokenCredentialAuthProvider = new TokenCredentialAuthProvider(SCOPE, clientSecretCredential);

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

and the error itself is here

    Exception in thread "Thread-8" java.lang.NoClassDefFoundError: com/azure/core/credential/TokenCredential

For context around this project we are deploying it through Tomcat 8.5+

Dercetus
  • 1
  • 1
  • You can check similar question - https://stackoverflow.com/questions/6334148/exception-in-thread-main-java-lang-noclassdeffounderror – vicky kumar Nov 16 '22 at 09:53

0 Answers0