I am running an AnyLogic Cloud model with a Blob Storage connection function for sending data to Azure Blob Storage.
I'm encountering an error at runtime when attempting to call the 'BlobServiceClientBuilder' method:
import com.azure.storage.blob.*;
import com.azure.storage.blob.models.*;
import java.io.*;
BlobServiceClient serviceClient = new BlobServiceClientBuilder()
.connectionString(<storageConnectionString>)
.buildClient();
// I've also tried:
BlobServiceClient serviceClient = new BlobServiceClientBuilder()
.endpoint(<endpointString>)
.connectionString(<storageConnectionString>)
.buildClient();
With a valid storageConnectionString
and endpointString
for the storage account.
The error I'm getting at runtime is the following:
java.lang.NoClassDefFoundError: com/azure/core/client/traits/TokenCredentialTrait
Given that I'm not trying to use SAS Tokens or credentials, and have opted for the connection string method (according to the Azure BlobServiceClientBuilder() documentation), I'm not sure what is causing the error.
Ideas that could be related:
Blocked access due to network security arrangements:
The virtual machine hosting the AnyLogic Cloud environment is on a virtual network peered with the virtual network where the storage account is located. The storage account has network integration and a private endpoint, so it could be a configuration issue, although the error message does not indicate this.
AnyLogic is a little bit janky sometimes and could be causing issues, although I have no idea what could be causing this issue.
Any suggestions would be greatly appreciated. I've seen a few posts here that are similar but have not been a solution for me - hoping this doesn't get a tonne of 'Duplicate' comments, but there we go!
The class BlobServiceClientBuilder
belongs to the package com.azure.storage.blob
and implements TokenCredentialTrait
interface (among other things). This interface belongs to another package com.azure.core.client.traits
.
It seems like you only included the JAR file for Microsoft Azure client library for Blob Storage but not the JAR file for Microsoft Azure Java Core Library.
Please keep in mind, that AnyLogic doesn't automatically search for and download the dependencies for external libraries. So you need to check the dependencies in the documentation and include all required JARs in your AnyLogic model.