java.lang.NoClassDefFoundError: com/azure/storage/common/policy/StorageBearerTokenChallengeAuthorizationPolicy

Rakesh Venkatesh 20 Reputation points
2024-11-04T12:14:30.14+00:00

Hello

I am using a spring boot Java application to upload files into data lake but I am getting below error when trying to run the application

Caused by: java.lang.NoClassDefFoundError: com/azure/storage/common/policy/StorageBearerTokenChallengeAuthorizationPolicy
[2024-11-04T12:09:01.174Z] 	at com.azure.storage.file.datalake.implementation.util.BuilderHelper.buildPipeline(BuilderHelper.java:131)
[2024-11-04T12:09:01.174Z] 	at com.azure.storage.file.datalake.DataLakeServiceClientBuilder.constructPipeline(DataLakeServiceClientBuilder.java:111)
[2024-11-04T12:09:01.174Z] 	at com.azure.storage.file.datalake.DataLakeServiceClientBuilder.buildAsyncClient(DataLakeServiceClientBuilder.java:142)
[2024-11-04T12:09:01.174Z] 	at com.azure.storage.file.datalake.DataLakeServiceClientBuilder.buildClient(DataLakeServiceClientBuilder.java:123)

Below are the application versions I am using

Spring boot : 3.2.8
Spring cloud: 2023.0.1
azure-functions-java-library: 3.1.0
azure-identity: 1.12.2
azure-storage-file-datalake: 12.21.0
azure-storage-blob: 12.18.0
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,192 questions
{count} votes

Accepted answer
  1. KarishmaTiwari-MSFT 20,772 Reputation points Microsoft Employee Moderator
    2024-11-06T00:23:18.3633333+00:00

    @Rakesh Venkatesh Thanks for sharing the update.

    #The Azure SDK for Java build tool, introduced in Get started with Azure SDK and Apache Maven, helps to identify commonly encountered issues. We recommend that you add this build tool to your project and run it by adding the azure:run Maven target to your regular build process. With the appropriate configuration, you can identify and resolve dependency conflicts more proactively, before they become issues at runtime.

    #Use the latest stable Azure SDK BOM and don't specify Azure SDK and dependency versions in your POM file. When applicable, use the Azure Spring Boot BOM.The dependencies listed in the Azure SDK BOM are tested rigorously to avoid dependency conflicts.

    #See Dependency Management for Java for information on the best way to prevent dependency version conflicts.
    Sometimes, a clean build can resolve classpath issues. Run mvn clean install to ensure that all dependencies are correctly resolved.

    Additional reading:
    [BUG] java.lang.NoClassDefFoundError: com/azure/core/implementation/util/ImplUtils · Issue #20362 · Azure/azure-sdk-for-java

    NoClassDefFoundError for com.azure.core.http.policy.HttpLoggingPolicy · Issue #11556 · Azure/azure-sdk-for-java

    Please go through the steps above and share the results.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Rakesh Venkatesh 20 Reputation points
    2024-11-04T22:49:37.97+00:00

    Hello Vinod

    Thanks for your reply. I included some dependencies which I have mentioned below and after that I am getting new errors which I have mentioned below. Can you let me know how to fix it?

    updated pom.xml file

    <dependency>
                <groupId>com.azure</groupId>
                <artifactId>azure-storage-file-datalake</artifactId>
                <version>12.21.0</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/com.azure/azure-storage-common -->
            <dependency>
                <groupId>com.azure</groupId>
                <artifactId>azure-storage-common</artifactId>
                <version>12.27.1</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/com.azure/azure-storage-blob -->
            <dependency>
                <groupId>com.azure</groupId>
                <artifactId>azure-storage-blob</artifactId>
                <version>12.28.1</version>
            </dependency>
    
    

    I tried with different version but still seeing same issue

    New error

    Exception: NoSuchFieldError: X_MS_REQUEST_ID
    [2024-11-04T22:45:02.452Z] Stack: java.lang.reflect.InvocationTargetException
    [2024-11-04T22:45:02.452Z] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [2024-11-04T22:45:02.452Z] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    [2024-11-04T22:45:02.452Z] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [2024-11-04T22:45:02.452Z] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    [2024-11-04T22:45:02.452Z] 	at com.microsoft.azure.functions.worker.broker.JavaMethodInvokeInfo.invoke(JavaMethodInvokeInfo.java:22)
    [2024-11-04T22:45:02.452Z] 	at com.microsoft.azure.functions.worker.broker.EnhancedJavaMethodExecutorImpl.execute(EnhancedJavaMethodExecutorImpl.java:22)
    [2024-11-04T22:45:02.452Z] 	at com.microsoft.azure.functions.worker.chain.FunctionExecutionMiddleware.invoke(FunctionExecutionMiddleware.java:19)
    [2024-11-04T22:45:02.452Z] 	at com.microsoft.azure.functions.worker.chain.InvocationChain.doNext(InvocationChain.java:21)
    [2024-11-04T22:45:02.452Z] 	at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:125)
    [2024-11-04T22:45:02.452Z] 	at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:34)
    [2024-11-04T22:45:02.452Z] 	at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
    [2024-11-04T22:45:02.452Z] 	at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:44)
    [2024-11-04T22:45:02.452Z] 	at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:94)
    [2024-11-04T22:45:02.452Z] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    [2024-11-04T22:45:02.452Z] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    [2024-11-04T22:45:02.452Z] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    [2024-11-04T22:45:02.452Z] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    [2024-11-04T22:45:02.452Z] 	at java.base/java.lang.Thread.run(Thread.java:833)
    [2024-11-04T22:45:02.452Z] Caused by: java.lang.NoSuchFieldError: X_MS_REQUEST_ID
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.