I am upgrading the azure sdk for java to version 12.21.1. The spring boot version is 2.1.6.
I am using the following dependency in gradle : implementation ‘com.azure:azure-storage-blob:12.21.1’ .
I am using the following code to create BlobServiceClient :
String accountUrl = "https://" + accountName + ".blob.core.windows.net";
StorageSharedKeyCredential sharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey);
try{
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().credential(sharedKeyCredential).endpoint(accountUrl).buildClient();
}
But it is throwing an error at runtime :
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: reactor/util/context/ContextView] with root cause
java.lang.ClassNotFoundException: reactor.util.context.ContextView
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na]
BuiltinClassLoader.java:581
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
ClassLoaders.java:178
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
ClassLoader.java:522
at com.azure.core.http.policy.HttpPolicyProviders.addAfterRetryPolicies(HttpPolicyProviders.java:52) ~[azure-core-1.37.0.jar:1.37.0]
HttpPolicyProviders.java:52
at com.azure.storage.blob.implementation.util.BuilderHelper.buildPipeline(BuilderHelper.java:128) ~[azure-storage-blob-12.21.1.jar:12.21.1]
BuilderHelper.java:128
at com.azure.storage.blob.BlobServiceClientBuilder.buildAsyncClient(BlobServiceClientBuilder.java:135) ~[azure-storage-blob-12.21.1.jar:12.21.1]
BlobServiceClientBuilder.java:135
at com.azure.storage.blob.BlobServiceClientBuilder.buildClient(BlobServiceClientBuilder.java:114) ~[azure-storage-blob-12.21.1.jar:12.21.1]
How to resolve this?
2
Answers
Looks like there was some dependency conflict between spring boot version and swagger . I upgraded spring boot to 2.7.10 and swagger to openAPI. This issue was resolved after that. Thanks.
This could be because of missing dependency in your application. Check if you have added the required dependencies to your project’s classpath.
I have reproduced your requirement to upload/download file using Azure Java SDK.
Below are the dependencies which I have used in my application.
Note the Access token of your storage account in the Azure portal:
I have created the simple API to call this method which is creating the file and downloading the file from Azure Blob Storage.
Calling the API which I have created and it is generating the url to download the file which has been uploaded as shown below:
Uploaded the file to Azure Blob Storage using the above code:
By using the above code, downloaded the file as data.txt.