0
votes

I am writing a java program to connect to Azure Data Lake Storage (ADLS Gen2). But when I try to iterate the file-system list of storage account I get "java.lang.NoSuchMethodError: reactor.core.publisher.Flux.toIterable(I)Ljava/lang/Iterable" error.

Stack trace:

HTTP Status 500 - Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: reactor.core.publisher.Flux.toIterable(I)Ljava/lang/Iterable;</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: reactor.core.publisher.Flux.toIterable(I)Ljava/lang/Iterable;</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: reactor.core.publisher.Flux.toIterable(I)Ljava/lang/Iterable; org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) javax.servlet.http.HttpServlet.service(HttpServlet.java:650) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) </pre></p><p><b>root cause</b> <pre>java.lang.NoSuchMethodError: reactor.core.publisher.Flux.toIterable(I)Ljava/lang/Iterable; com.azure.core.util.IterableStream.iterator(IterableStream.java:85) 

Code Sample:

    ClientSecretCredential servicePrincipalCreds  = new ClientSecretCredentialBuilder()
                    .clientId(clientID)
                    .clientSecret(clientSecret)
                    .tenantId(tenantID)
                    .build();
                    
    DataLakeServiceClient dataLakeServiceClient = new DataLakeServiceClientBuilder()
                    .endpoint("https://"+accountName+".dfs.core.windows.net")
                    .credential(servicePrincipalCreds)
                    .httpClient(new OkHttpAsyncHttpClientBuilder().build())
                    .buildClient();
    
    PagedIterable<FileSystemItem> pageItr = dataLakeServiceClient.listFileSystems();
    Iterator<FileSystemItem> itr = pageItr.iterator(); // Here I get error
            while(itr.hasNext()){
                FileSystemItem fileSystemItem = itr.next();
                if(fileSystemItem.getName().equals(fileSystemName)){
                    System.out.println("FileSystem Exist:: "+fileSystemName);
                    break;
                }
            }

Below is pom.xml

        <dependencies>
       <dependency>
          <groupId>com.azure</groupId>
          <artifactId>azure-storage-file-datalake</artifactId>
          <version>12.2.0-beta.1</version>
          <exclusions>
             <exclusion>
                <groupId>com.azure</groupId>
                <artifactId>azure-core-http-netty</artifactId>
             </exclusion>
          </exclusions>
       </dependency>
       <dependency>
          <groupId>com.azure</groupId>
          <artifactId>azure-identity</artifactId>
          <version>1.0.8</version>
       </dependency>
       <dependency>
          <groupId>com.azure</groupId>
          <artifactId>azure-core-http-okhttp</artifactId>
          <version>1.2.4</version>
       </dependency>
       <dependency>
          <groupId>com.azure</groupId>
          <artifactId>azure-core</artifactId>
          <version>1.6.0</version>
       </dependency>
       <dependency>
          <groupId>com.azure</groupId>
          <artifactId>azure-storage-blob</artifactId>
          <version>12.8.0-beta.1</version>
          <exclusions>
             <exclusion>
                <groupId>com.azure</groupId>
                <artifactId>azure-core-http-netty</artifactId>
             </exclusion>
          </exclusions>
       </dependency>
       <dependency>
          <groupId>com.azure</groupId>
          <artifactId>azure-storage-common</artifactId>
          <version>12.8.0-beta.1</version>
          <exclusions>
             <exclusion>
                <groupId>com.azure</groupId>
                <artifactId>azure-core-http-netty</artifactId>
             </exclusion>
          </exclusions>
       </dependency>
       <dependency>
          <groupId>com.azure</groupId>
          <artifactId>azure-storage-internal-avro</artifactId>
          <version>12.0.0-beta.1</version>
       </dependency>
    </dependencies>

Though the reactor-core dependency comes with above dependencies. Still I tried adding it explicitly but it didn't resolve the issue.

Any help will be highly appreciated. Thanks in advance.

1

1 Answers

0
votes

I have tried your code and it works on my side. import class:

import com.azure.core.http.okhttp.OkHttpAsyncHttpClientBuilder;
import com.azure.core.http.rest.PagedIterable;
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.azure.storage.file.datalake.DataLakeServiceClient;
import com.azure.storage.file.datalake.DataLakeServiceClientBuilder;
import com.azure.storage.file.datalake.models.FileSystemItem;
import java.util.Iterator;

you can use this to have a try.