binarywang/WxJava · error · IllegalArgumentException

不支持的http执行器类型:{requestType}

Error message

不支持的http执行器类型:{requestType}

What it means

ChannelFileUploadRequestExecutor.create switches on the configured HttpClientType and only provides implementations for APACHE_HTTP and HTTP_COMPONENTS (Apache HttpClient 4.x and 5.x). Any other client type — JODD_HTTP or OK_HTTP — falls through to the default branch and throws. The Channel module simply does not ship Jodd/OkHttp upload executors.

Source

Thrown at weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelFileUploadRequestExecutor.java:31

public abstract class ChannelFileUploadRequestExecutor<H, P> implements RequestExecutor<String, File> {

  protected RequestHttp<H, P> requestHttp;

  public ChannelFileUploadRequestExecutor(RequestHttp<H, P> requestHttp) {
    this.requestHttp = requestHttp;
  }

  @SuppressWarnings("unchecked")
  public static RequestExecutor<String, File> create(RequestHttp<?, ?> requestHttp) {
    switch (requestHttp.getRequestType()) {
      case APACHE_HTTP:
        return new ApacheHttpChannelFileUploadRequestExecutor(
          (RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
      case HTTP_COMPONENTS:
        return new HttpComponentsChannelFileUploadRequestExecutor(
          (RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
      default:
        throw new IllegalArgumentException("不支持的http执行器类型:" + requestHttp.getRequestType());
    }
  }

}

View on GitHub (pinned to 1c43293a3c)

Solutions

  1. Configure the Channel service with Apache HttpClient 4.x (APACHE_HTTP) or 5.x (HTTP_COMPONENTS) as its RequestHttp backend.
  2. If you must use a different client for other modules, give the Channel service its own dedicated Apache-based WxHttpClient.
  3. Check requestHttp.getRequestType() at startup and fail fast with a clear message if it is not supported for uploads.

Example fix

// before — shared OkHttp config breaks channel uploads
WxChannelService service = new WxChannelServiceImpl();
service.setWxHttpService(okHttpService); // OK_HTTP
service.uploadFile(...); // throws

// after — Apache HttpClient for channel
service.setWxHttpService(apacheHttpService); // APACHE_HTTP
service.uploadFile(...);
Defensive patterns

Strategy: validation

Validate before calling

Set<HttpClientType> supported = EnumSet.of(HttpClientType.APACHE_HTTP, HttpClientType.HTTP_COMPONENTS);
if (!supported.contains(requestHttp.getRequestType())) {
  throw new IllegalStateException("Channel file upload requires Apache HttpClient, got " + requestHttp.getRequestType());
}

Type guard

private static boolean channelUploadSupported(RequestHttp<?,?> http) {
  HttpClientType t = http.getRequestType();
  return t == HttpClientType.APACHE_HTTP || t == HttpClientType.HTTP_COMPONENTS;
}

Try / catch

try {
  service.uploadFile(...);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("不支持的http执行器类型")) {
    // switch the Channel service to Apache HttpClient
  }
  throw e;
}

Prevention

When it happens

Trigger: The WxChannelService is configured with an OkHttp or Jodd RequestHttp backend, and a file upload API (any method routed through ChannelFileUploadRequestExecutor) is invoked.

Common situations: Sharing an HTTP client config across modules where MP/MiniApp support OkHttp/Jodd but Channel does not; upgrading a multi-module app to OkHttp without checking Channel upload coverage.

Related errors


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