I wrote below code to connect to Azure Blob Storage and list all files present in it.I get the error in eclipse and tried different ways but not helping.
**Exception in thread "main" java.lang.NoSuchMethodError: 'java.lang.String io.netty.util.internal.ObjectUtil.checkNonEmptyAfterTrim(java.lang.String, java.lang.String)'
at io.netty.handler.codec.http.HttpMethod.<init>(HttpMethod.java:123)
at io.netty.handler.codec.http.HttpMethod.<clinit>(HttpMethod.java:36)
at reactor.netty.http.client.HttpClientConfig.<init>(HttpClientConfig.java:334)
at reactor.netty.http.client.HttpClientConnect.<init>(HttpClientConnect.java:86)
at reactor.netty.http.client.HttpClient.create(HttpClient.java:392)
at com.azure.core.http.netty.NettyAsyncHttpClientBuilder.build(NettyAsyncHttpClientBuilder.java:141)
at com.azure.core.http.netty.NettyAsyncHttpClientProvider.createInstance(NettyAsyncHttpClientProvider.java:52)
at com.azure.core.implementation.http.HttpClientProviders.createInstance(HttpClientProviders.java:67)
at com.azure.core.http.HttpClient.createDefault(HttpClient.java:50)
at com.azure.core.http.HttpClient.createDefault(HttpClient.java:40)
at com.azure.core.http.HttpPipelineBuilder.build(HttpPipelineBuilder.java:73)
at com.azure.storage.blob.implementation.util.BuilderHelper.buildPipeline(BuilderHelper.java:138)
at com.azure.storage.blob.BlobServiceClientBuilder.buildAsyncClient(BlobServiceClientBuilder.java:135)
at com.azure.storage.blob.BlobServiceClientBuilder.buildClient(BlobServiceClientBuilder.java:114)
at com.oq.sap.azure.MarketerIndentFile.main(MarketerIndentFile.java:81)**
This is the code. Please check below. I tried to add some jars in the eclipse project but it keeps complaining about the method error. I'm trying to connect to Azure blob container and then download some files using java code. After that I want to perform few more operations.
package com.azure;
import java.io.IOException;
import java.util.Locale;
import com.azure.core.credential.AzureSasCredential;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
/**
* This example shows how to start using the Azure Storage Blob SDK for Java.
*/
public class BlobFile{
/**
* Entry point into the basic examples for Storage blobs.
*
* @param args Unused. Arguments to the program.
* @throws IOException If an I/O error occurs
* @throws RuntimeException If the downloaded data doesn't match the uploaded
* data
*/
public static void main(String[] args) throws IOException {
AzureSasCredential sas = new AzureSasCredential("?sv=2020-10-02&si=xxx&sr=c&sig=xxx");
String endpoint = String.format(Locale.ROOT,
"https://XYZ.blob.core.windows.net", "ABC");
String containerName = "container name";
BlobServiceClient BlobServiceClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(sas).buildClient();
BlobContainerClient blobContainerClient = BlobServiceClient.getBlobContainerClient(containerName);
System.out.println("Listing blobs in the container: " + blobContainerClient.getBlobContainerUrl());
blobContainerClient.listBlobs()
.forEach(
blobItem -> System.out.println("This is the blob name: " + blobItem.getName()));
}
}
My Blob structure looks like below.
List of jars used in the eclipse project.