enter org.springframework.meption is javax.mail.NoSuchProviderException: imap
at org.springframework.integration.mail.MailReceivingMessageSource.receive(MailReceivingMessageSource.java:125)
at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:175
at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:224)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:57)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:176)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:173)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:330)
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:324)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:483)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:316)
at org.springframework.scheduling.commonj.TimerManagerTaskScheduler$TimerScheduledFuture.timerExpired(TimerManagerTaskSched
at org.springframework.scheduling.commonj.TimerManagerTaskScheduler$ReschedulingTimerListener.timerExpired(TimerManagerTask
at com.ibm.ws.asynchbeans.timer.TimerImpl.callListenerMethod(TimerImpl.java:361)
at com.ibm.ws.asynchbeans.timer.GenericTimer.run(GenericTimer.java:228)
at com.ibm.ws.asynchbeans.J2EEContext$RunProxy.run(J2EEContext.java:267)
at java.security.AccessController.doPrivileged(AccessController.java:390)
at javax.security.auth.Subject.doAs(Subject.java:494)
at com.ibm.websphere.security.auth.WSSubject.doAs(WSSubject.java:133)
at com.ibm.websphere.security.auth.WSSubject.doAs(WSSubject.java:91)
at com.ibm.ws.asynchbeans.J2EEContext$DoAsProxy.run(J2EEContext.java:338)
at java.security.AccessController.doPrivileged(AccessController.java:420)
at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:1174)
at com.ibm.ws.asynchbeans.timer.TimerImpl.runListenerAsCJWork(TimerImpl.java:490)
at com.ibm.ws.asynchbeans.am._Alarm.fireAlarm(_Alarm.java:340)
at com.ibm.ws.asynchbeans.am._Alarm.run(_Alarm.java:237)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1881)
Caused by: javax.mail.NoSuchProviderException: imap
at javax.mail.Session.getService(Session.java:798)
at javax.mail.Session.getStore(Session.java:578)
at javax.mail.Session.getStore(Session.java:540)
at org.springframework.integration.mail.AbstractMailReceiver.connectStoreIfNecessary(AbstractMailReceiver.java:239)
at org.springframework.integration.mail.AbstractMailReceiver.openFolder(AbstractMailReceiver.java:259)
at org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:285)
at org.springframework.integration.mail.MailReceivingMessageSource.receive(MailReceivingMessageSource.java:111)
... 29 morecode here
我可以ping远程服务器ip,因此没有连接问题。 我可以在tomcat中运行相同的代码,并且工作正常。 当我在web领域部署它时,相同的代码给我上面的错误。 尝试堆栈溢出的其他东西没有工作。 罐子是activation-1.1.jar,mail-1.4.5.jar。 任何指针都有帮助。
答案 0 :(得分:1)
好吧,在我们的测试中,我们将这个Gradle依赖项用于邮件适配器:
mailVersion = '1.5.5'
testRuntime "com.sun.mail:javax.mail:$mailVersion"
testRuntime "com.sun.mail:smtp:$mailVersion"
testRuntime "com.sun.mail:pop3:$mailVersion"
testRuntime "com.sun.mail:imap:$mailVersion"
因此,请考虑为您的项目添加com.sun.mail:imap:1.5.5
。
答案 1 :(得分:1)
感谢您的回答,评论肯定有帮助。
最初我使用了以下代码: -
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.3</version>
</dependency>
这解决了imap提供商的问题。所有都在本地工作但是当我在Websphere上部署代码时,我得到了类转换异常
caused by: java.lang.ClassCastException: com.sun.mail.handlers.text_plain incompatible with javax.activation.DataContentHandler
尽管text_plain从DataContenHandler扩展但仍在抱怨不同的类,它告诉它在其他地方被加载。然后排除激活jar,如下所示,以使其工作
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.3</version>
<exclusions>
<exclusion>
<artifactId>activation</artifactId>
<groupId>javax.activation</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.3</version>
<exclusions>
<exclusion>
<artifactId>activation</artifactId>
<groupId>javax.activation</groupId>
</exclusion>
</exclusions>
</dependency>
谢谢你们。