无法在 Runnable 或 Spring Controller 中实例化 EWS ExchangeService
Unable to instantiate EWS ExchangeService in Runnable or Spring Controller
我在 TimerTask
中有一个 EWS 服务,但它在实例化 new ExchangeService(ExchangeVersion.Exchange2010_SP2)
时抛出异常,并且它在 spring-web-mvc Controller 方法中不起作用,该方法使用 @RequestMapping
但实例化在 Non-Runnable
Class.
中工作得很好
public class AutoEmailTicketing extends TimerTask {
@Override
public void run() {
microsoft.exchange.webservices.data.ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.setCredentials(new WebCredentials(email, password));
service.autodiscoverUrl(email, new RedirectionUrlCallback());
service.setTraceEnabled(true);
Folder inbox = Folder.bind(service, WellKnownFolderName.Inbox);
}
}
用过的罐子...
commons-codec-1.7.jar
commons-logging-1.1.1.jar
commons-beanutils-1.8.2.jar
EWSJavaAPI_1.2.1.jar
EWSJavaAPI_1.2original.jar
EWSJavaAPIWithJars_1.2.1.jar
jcifs-1.3.17.jar
httpclient-4.2.5.jar
httpcore-4.2.4.jar
异常日志如下...
Exception in thread "Timer-0" java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:47)
at org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:93)
at microsoft.exchange.webservices.data.ExchangeServiceBase.<init>(Unknown Source)
at microsoft.exchange.webservices.data.ExchangeService.<init>(Unknown Source)
at com.mbl.messaging.service.ews.AutoEmailTicketing.run(AutoEmailTicketing.java:4)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
终于在Here找到了解决办法。我用过...
httpclient-4.2.jar
httpcore-4.2.jar
joda-time-2.9.9.jar
不知道joda-time
靠不靠
我在 TimerTask
中有一个 EWS 服务,但它在实例化 new ExchangeService(ExchangeVersion.Exchange2010_SP2)
时抛出异常,并且它在 spring-web-mvc Controller 方法中不起作用,该方法使用 @RequestMapping
但实例化在 Non-Runnable
Class.
public class AutoEmailTicketing extends TimerTask {
@Override
public void run() {
microsoft.exchange.webservices.data.ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.setCredentials(new WebCredentials(email, password));
service.autodiscoverUrl(email, new RedirectionUrlCallback());
service.setTraceEnabled(true);
Folder inbox = Folder.bind(service, WellKnownFolderName.Inbox);
}
}
用过的罐子...
commons-codec-1.7.jar
commons-logging-1.1.1.jar
commons-beanutils-1.8.2.jar
EWSJavaAPI_1.2.1.jar
EWSJavaAPI_1.2original.jar
EWSJavaAPIWithJars_1.2.1.jar
jcifs-1.3.17.jar
httpclient-4.2.5.jar
httpcore-4.2.4.jar
异常日志如下...
Exception in thread "Timer-0" java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:47)
at org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:93)
at microsoft.exchange.webservices.data.ExchangeServiceBase.<init>(Unknown Source)
at microsoft.exchange.webservices.data.ExchangeService.<init>(Unknown Source)
at com.mbl.messaging.service.ews.AutoEmailTicketing.run(AutoEmailTicketing.java:4)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
终于在Here找到了解决办法。我用过...
httpclient-4.2.jar
httpcore-4.2.jar
joda-time-2.9.9.jar
不知道joda-time
靠不靠