Search code examples
javanoclassdeffounderrorexchangewebservicesewsjavaapi

Java EWS throws NoClassDefFound


I want to read the Outlook calendar. So I'm started first to try to connect to the server. I found http://code.msdn.microsoft.com/exchange-ews-java-api-12-1a5a1143 and want just to get the connect and try around.

I found a example and tried this:

import microsoft.exchange.webservices.data.*;
...
public void test(){     
    ExchangeService es = new ExchangeService();
    ExchangeCredentials credentials = new WebCredentials("user", "Password");
}

It crashes by Exchange Service:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpConnectionManager
at ExchangeTest.test(ExchangeTest.java:15)
at Window.main(Window.java:19)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpConnectionManager
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 2 more

I tried to import a library but didn't got the correct one or the fault is something else. Can you tell me which library I need or where/how I can fix it. Thanks.

I'm using a Win7.


Solution

  • You need this library The Commons HttpClient and you have to add this library to the build path of your project.