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

Eclipse Oxygen运行Java代码遇NoClassDefFoundError求助

解决Java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager问题

Hey there, I’ve dealt with this exact headache when working with Exchange Web Services in Eclipse, so let’s break down what’s going on and fix it:

问题根源

That NoClassDefFoundError tells us a key detail: even though your import statements work fine (Eclipse can find the EWS classes at compile time), your runtime classpath is missing the Apache HttpClient dependencies that ExchangeService relies on. The HttpClientConnectionManager class is part of the Apache HttpClient library—this is a hidden dependency that your EWS JAR needs but isn’t included with it.

分步解决方案

  • Grab the required Apache HttpClient JARs
    You need at least these two core JARs (make sure their versions match what your EWS library expects):

    • httpclient.jar
    • httpcore.jar
      If you’re unsure which versions to pick, check your EWS JAR’s META-INF/MANIFEST.MF file—it’ll list the exact dependencies it requires.
  • Make sure Eclipse recognizes the JARs at runtime
    Just copying JARs into your lib folder isn’t enough. You need to add them to the build path:

    1. Right-click your project in the Package Explorer
    2. Hover over Build Path > Select Add External Archives... (or Add Libraries... if you’ve already moved the JARs into your project’s lib folder)
    3. Navigate to the HttpClient JARs you downloaded and add them
    4. Confirm they show up under Referenced Libraries in your project
  • Clean and rebuild your project
    Eclipse’s build cache can sometimes cause weird classpath glitches:

    1. Go to Project > Clean...
    2. Select your project and click OK
    3. Let the rebuild finish, then run your test class again
  • Check for version mismatches
    Older EWS versions often depend on specific Apache HttpClient versions (like 4.5.x instead of the latest 5.x). If you mixed a new HttpClient JAR with an old EWS JAR, this mismatch will trigger class-not-found errors. Stick to the dependency versions recommended by your EWS library.

你的代码参考

package com.ed;
import microsoft.exchange.webservices.data.core.ExchangeService;
public class Test {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        ExchangeService service = new ExchangeService();
    }
}

错误信息回顾

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager
at com.ed.Test.main(Test.java:8)
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.HttpClientConnectionManager
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 07:36:30