binarywang/WxJava · error · WxErrorException

上传失败,服务器响应空 url:%s param:%s

Error message

上传失败,服务器响应空 url:%s param:%s

What it means

The Jodd HTTP upload executor throws when response.bodyText() is empty after the multipart POST. Same fast-fail contract as the Apache variants: an empty body cannot be turned into a WxError, so it throws with the URL and param. Note Jodd uses responseContent.isEmpty() (not StringUtils.isEmpty), so only truly empty strings trigger this.

Source

Thrown at weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorJoddHttpImpl.java:54

    HttpRequest request = HttpRequest.post(uri);
    if (requestHttp.getRequestHttpProxy() != null) {
      requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
    }
    request.withConnectionProvider(requestHttp.getRequestHttpClient());
    request.form(param.getName(), new CommonUploadParamToUploadableAdapter(param.getData()));

    // 添加额外的表单字段
    if (param.getFormFields() != null && !param.getFormFields().isEmpty()) {
      for (java.util.Map.Entry<String, String> entry : param.getFormFields().entrySet()) {
        request.form(entry.getKey(), entry.getValue());
      }
    }

    HttpResponse response = request.send();
    response.charset(StandardCharsets.UTF_8.name());
    String responseContent = response.bodyText();
    if (responseContent.isEmpty()) {
      throw new WxErrorException(String.format("上传失败,服务器响应空 url:%s param:%s", uri, param));
    }
    WxError error = WxError.fromJson(responseContent, wxType);
    if (error.getErrorCode() != 0) {
      throw new WxErrorException(error);
    }
    return responseContent;
  }

  /**
   * 通用上传参数 到 Uploadable 的适配器
   */
  @Getter
  @AllArgsConstructor
  public static class CommonUploadParamToUploadableAdapter implements Uploadable<CommonUploadData> {

    private CommonUploadData content;

    @SneakyThrows

View on GitHub (pinned to 1c43293a3c)

Solutions

  1. Retry once — empty responses are usually transient.
  2. Verify apiHostUrl and any proxy in front of the Jodd client.
  3. Switch to Apache HttpClient (4.x/5.x) if Jodd upload reliability is poor in your environment.
  4. Log HTTP status/headers to identify the layer returning empty.

Example fix

// before
String r = service.upload(param);

// after
try {
  return service.upload(param);
} catch (WxErrorException e) {
  if (e.getMessage() != null && e.getMessage().contains("服务器响应空")) {
    return service.upload(param);
  }
  throw e;
}
Defensive patterns

Strategy: retry

Try / catch

int attempts = 0;
while (true) {
  try {
    return service.upload(param);
  } catch (WxErrorException e) {
    boolean empty = e.getMessage() != null && e.getMessage().contains("服务器响应空");
    if (!empty || ++attempts > 2) throw e;
    Thread.sleep(1000L * attempts);
  }
}

Prevention

When it happens

Trigger: The Jodd backend receives HTTP 200 with an empty body during upload; a proxy/gateway strips the response; the endpoint returns an empty page.

Common situations: Jodd-configured service behind a WAF/proxy that returns empty; transient infra issues; incorrect endpoint returning an empty body.

Related errors


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