You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Java SDK V12:解决BlobServiceClientBuilder的NoClassDefFoundError错误

问题描述

运行带有Blob存储连接功能的AnyLogic Cloud模型,尝试将数据发送至Azure Blob存储时,调用BlobServiceClientBuilder出现运行时错误。

使用的代码:

import com.azure.storage.blob.*;
import com.azure.storage.blob.models.*;
import java.io.*;

BlobServiceClient serviceClient = new BlobServiceClientBuilder()
        .connectionString(<storageConnectionString>)
        .buildClient();

// 也曾尝试:
BlobServiceClient serviceClient = new BlobServiceClientBuilder()
        .endpoint(<endpointString>)
        .connectionString(<storageConnectionString>)
        .buildClient();

已确认使用的storageConnectionString和endpointString均有效,但报错信息如下:

java.lang.NoClassDefFoundError: com/azure/core/client/traits/TokenCredentialTrait
解决建议
  • 确保Azure SDK依赖版本一致:TokenCredentialTrait类属于Azure Core SDK包,需保证azure-storage-blob与azure-core的版本完全匹配(比如均为12.25.0等同主版本号)。版本不兼容会导致类找不到的问题。
  • 完整添加Azure依赖库:在AnyLogic项目中手动添加azure-core和azure-storage-blob的jar文件到项目lib目录,并在AnyLogic的「项目设置-库」中勾选这些依赖,确保运行时能加载到所有必要的类。
  • 排查依赖冲突:检查AnyLogic自带的库中是否存在旧版本的Azure相关jar包,若有则移除,避免与你引入的SDK版本冲突。
  • 验证连接字符串格式:确认连接字符串格式正确,示例格式为:DefaultEndpointsProtocol=https;AccountName=你的存储账户名;AccountKey=你的账户密钥;EndpointSuffix=core.windows.net,避免出现拼写或符号错误。
  • 检查AnyLogic Cloud网络权限:若本地运行正常但Cloud环境报错,需确认AnyLogic Cloud的运行环境允许出站访问Azure Blob存储的HTTPS端口(443),没有被防火墙或网络策略限制。

内容的提问来源于stack exchange,提问作者Svengineer91

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 06:21:57