binarywang/WxJava · error · WxErrorException

请配置会话存档sdk文件的路径,不要配错了!!

Error message

请配置会话存档sdk文件的路径,不要配错了!!

What it means

Thrown as WxErrorException (checked) in createSdk() when configStorage.getMsgAuditLibPath() returns null or empty. The msgAuditLibPath must point to the native Finance SDK library files (e.g., libWeWorkFinanceSdk.so on Linux, WeWorkFinanceSdk.dll on Windows) that are required to initialize the conversation archive JNI bridge.

Source

Thrown at weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMsgAuditServiceImpl.java:109

    long newSdk = createSdk();
    threadLocalSdk.set(newSdk);
    managedSdks.add(newSdk);
    log.info("线程 [{}] 初始化会话存档SDK成功,sdk={}", Thread.currentThread().getName(), newSdk);
    return newSdk;
  }

  /**
   * 创建并初始化一个新的会话存档 SDK 实例。
   * <p>通常通过 {@link #getOrInitThreadLocalSdk()} 间接调用以复用 ThreadLocal 中的实例;
   * 旧版直接暴露 sdk 的 API(如 {@link #getChatDatas})也会直接调用本方法,此时 SDK 由调用方自行管理。</p>
   * <p>Finance.loadingLibraries() 底层依赖 System.load(),JVM 保证同一库不重复加载,多线程并发调用安全。</p>
   */
  private long createSdk() throws WxErrorException {
    WxCpConfigStorage configStorage = cpService.getWxCpConfigStorage();

    String configPath = configStorage.getMsgAuditLibPath();
    if (StringUtils.isEmpty(configPath)) {
      throw new WxErrorException("请配置会话存档sdk文件的路径,不要配错了!!");
    }

    // 替换斜杠
    String replacePath = configPath.replace("\\", "/");
    // 获取最后一个斜杠的下标,用作分割路径
    int lastIndex = replacePath.lastIndexOf("/") + 1;
    // 获取完整路径的前缀路径
    String prefixPath = replacePath.substring(0, lastIndex);
    // 获取后缀的所有文件,目的遍历所有文件
    String suffixFiles = replacePath.substring(lastIndex);

    // 包含so文件
    String[] libFiles = suffixFiles.split(",");
    if (libFiles.length <= 0) {
      throw new WxErrorException("请仔细配置会话存档文件路径!!");
    }

    List<String> libList = Arrays.asList(libFiles);

View on GitHub (pinned to 1c43293a3c)

Solutions

  1. Download the Finance SDK from WeCom admin console (管理工具 > 会话内容存档) and set the path: config.setMsgAuditLibPath("/opt/wecom/finance/libWeWorkFinanceSdk.so").
  2. On Windows, specify multiple DLL files comma-separated in dependency order: config.setMsgAuditLibPath("C:/wecom/lib.dll,WeWorkFinanceSdk.dll").
  3. Verify the path is absolute and the JVM process has read access to the library files.

Example fix

// before
WxCpDefaultConfigImpl config = new WxCpDefaultConfigImpl();
config.setCorpId("corpId");
config.setCorpSecret("secret");
// msgAuditLibPath not set
cpService.getMsgAuditService().getChatDatas(0, 1000, null, null, 30); // throws

// after
config.setMsgAuditLibPath("/opt/wecom/finance/libWeWorkFinanceSdk_Java.so");
cpService.getMsgAuditService().getChatDatas(0, 1000, null, null, 30);
Defensive patterns

Strategy: validation

Validate before calling

String libPath = cpService.getWxCpConfigStorage().getMsgAuditLibPath();
if (StringUtils.isEmpty(libPath)) {
    throw new IllegalStateException("msgAuditLibPath is not configured; download the Finance SDK and set the path");
}

Prevention

When it happens

Trigger: Calling any conversation archive API (getChatDatas, getDecryptData, etc.) without having configured the msgAuditLibPath on the WxCpConfigStorage. This is the first check in createSdk() and fires before any library loading.

Common situations: Developer sets up WxCpDefaultConfigImpl with corpId and secret but forgets to download and configure the native Finance SDK library files. Or they set the path to a property key name instead of the actual filesystem path.

Related errors


AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14). Data as JSON: /api/errors/2ae7aaec1271ead2. Report an issue: GitHub.