Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class not found error in SDK 6.6.0 : com.microsoft.kiota.authentication.ObservabilityOptions #1942

Open
m-moris opened this issue Apr 19, 2024 · 1 comment
Labels

Comments

@m-moris
Copy link

m-moris commented Apr 19, 2024

I am testing the latest version (6.6.0) of Graph SDK with a small program, but I am encountering a compile error due to a dependency issue.

Expected behavior

The program should compile and run properly.

Actual behavior

The following error occurs and prevents the program from compiling:

[INFO] BUILD FAILURE  
[INFO] ------------------------------------------------------------------------  
[INFO] Total time: 1.806 s  
[INFO] Finished at: 2024-04-19T13:37:58+09:00  
[INFO] ------------------------------------------------------------------------  
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project graph-sample: Compilation failure  
[ERROR] /home/moris/w/graph-sample/src/main/java/org/example/App.java:[21,38] cannot access com.microsoft.kiota.authentication.ObservabilityOptions  
[ERROR]   class file for com.microsoft.kiota.authentication.ObservabilityOptions not found  
[ERROR]   

In vscode message:

The project was not built since its build path is incomplete. Cannot find the class file for com.microsoft.kiota.authentication.ObservabilityOptions. Fix the build path then try   

Steps to reproduce the behavior

The Maven dependencies are as follows. I have set it up according to the README.md

  <dependencies>  
    <dependency>  
      <groupId>com.microsoft.graph</groupId>  
      <artifactId>microsoft-graph</artifactId>  
      <version>6.6.0</version>  
    </dependency>  
    <dependency>  
      <groupId>com.azure</groupId>  
      <artifactId>azure-identity</artifactId>  
      <version>1.11.0</version>  
    </dependency>  
  </dependencies>  

The program is as follows:

package org.example;  
   
import com.azure.identity.ClientSecretCredential;  
import com.azure.identity.ClientSecretCredentialBuilder;  
import com.microsoft.graph.core.authentication.AzureIdentityAuthenticationProvider;  
import com.microsoft.graph.serviceclient.GraphServiceClient;  
   
public class App {  
    public static void main(String[] args) {  
  
        String clientId = System.getenv("CLIENT_ID");  
        String clientSecret = System.getenv("CLIENT_SECRET");  
        String tenantId = System.getenv("TENANT_ID");  
  
        ClientSecretCredential creds = new ClientSecretCredentialBuilder()  
            .clientId(clientId)  
            .clientSecret(clientSecret)  
            .tenantId(tenantId)  
            .build();  
  
        var authenticationProvider = new AzureIdentityAuthenticationProvider(creds, null,  
            "https://graph.microsoft.com/.default");  
        GraphServiceClient graphClient = new GraphServiceClient(authenticationProvider);  
        var result = graphClient.users().byUserId("your user id").get();  
        System.out.println(result.getDisplayName());  
        System.out.println(result.getUserPrincipalName());  
    }  
}  

If the following dependency is added manually, it can compile and run correctly:

    <dependency>  
      <groupId>com.microsoft.kiota</groupId>  
      <artifactId>microsoft-kiota-authentication-azure</artifactId>  
      <version>1.1.4</version>  
    </dependency>   
@Ndiritu
Copy link
Contributor

Ndiritu commented Apr 22, 2024

Thanks for reporting this @m-moris.

In the interim, for your scenario you can initialise your Graph client using:

GraphServiceClient client = new GraphServiceClient(credential, "https://graph.microsoft.com/.default");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants