You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Guillermo <gl...@tecsisa.com> on 2013/08/29 14:45:52 UTC

How to poll Google mail inbox for mails

Hi,

I'm writting because I'm trying to poll my Google mail inbox for mails. I
changed the settings of my Google mail account to allow IMAP access but I'm
having some problems.

This is my basic route definition:

from("imap://imap.gmail.com?username=myusername@gmail.com&password=mypassword&delete=false&unseen=true&consumer.delay=60000").to("log:newmail");

An exception is thrown when the polling is performed:

Consumer
Consumer[imap://imap.gmail.com?consumer.delay=60000&delete=false&password=******&unseen=true&username=myusername%40gmail.com]
could not poll endpoint:
Endpoint[imap://imap.gmail.com?consumer.delay=60000&delete=false&password=******&unseen=true&username=myusername%40gmail.com]
caused by: Connection timed out: connect
javax.mail.MessagingException: Connection timed out: connect
	at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at javax.mail.Service.connect(Service.java:288)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at
org.apache.camel.component.mail.MailConsumer.ensureIsConnected(MailConsumer.java:376)
~[camel-mail-2.10.1.jar:2.10.1]
	at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:82)
~[camel-mail-2.10.1.jar:2.10.1]
	at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:139)
[camel-core-2.10.1.jar:2.10.1]
	at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:91)
[camel-core-2.10.1.jar:2.10.1]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
[na:1.7.0_11]
	at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
[na:1.7.0_11]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
[na:1.7.0_11]
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
[na:1.7.0_11]
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[na:1.7.0_11]
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
[na:1.7.0_11]
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
[na:1.7.0_11]
	at java.lang.Thread.run(Thread.java:722) [na:1.7.0_11]
Caused by: java.net.ConnectException: Connection timed out: connect
	at java.net.DualStackPlainSocketImpl.connect0(Native Method) ~[na:1.7.0_11]
	at
java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
~[na:1.7.0_11]
	at
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
~[na:1.7.0_11]
	at
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
~[na:1.7.0_11]
	at
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
~[na:1.7.0_11]
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
~[na:1.7.0_11]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
~[na:1.7.0_11]
	at java.net.Socket.connect(Socket.java:579) ~[na:1.7.0_11]
	at java.net.Socket.connect(Socket.java:528) ~[na:1.7.0_11]
	at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	... 13 common frames omitted

What's wrong? What is the correct way to poll the Google mail inbox using
imap or imaps?

Thanks in advance.

Guillermo.

Additional info:
Using camel version 2.10.1



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-poll-Google-mail-inbox-for-mails-tp5738222.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to poll Google mail inbox for mails

Posted by Guillermo <gl...@tecsisa.com>.
Thanks for your reply. I have seen that the problem was not in my Java
installation. The problem was that the application server (weblogic) did not
have the imap.gmail.com certificate imported. I have followed the
instructions that are explained in the link of stackoverflow to do that.

Thanks.



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-poll-Google-mail-inbox-for-mails-tp5738222p5738302.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to poll Google mail inbox for mails

Posted by James Green <ja...@gmail.com>.
http://stackoverflow.com/questions/9619030/resolving-javax-net-ssl-sslhandshakeexception-sun-security-validator-validatore

A more interesting question is why your Java installation does not
recognise the Google CA certificate. Either your installation is old or
Oracle isn't updating the shipped certificates.


On 29 August 2013 14:05, Guillermo <gl...@tecsisa.com> wrote:

> Ok, i think that connecting with protocol imap (IMAP without SSL) does not
> work because isn't supported by GMail. I need to use imaps (IMAP with SSL).
> But in that case i still have a problem:
>
> Consumer
> Consumer[imaps://
> imap.gmail.com?consumer.delay=60000&delete=false&password=******&unseen=true&username=myusername%40gmail.com
> ]
> could not poll endpoint:
> Endpoint[imaps://
> imap.gmail.com?consumer.delay=60000&delete=false&password=******&unseen=true&username=myusername%40gmail.com
> ]
> caused by: sun.security.validator.ValidatorException: PKIX path building
> failed: sun.security.provider.certpath.SunCertPathBuilderException: unable
> to find valid certification path to requested target
> javax.mail.MessagingException: sun.security.validator.ValidatorException:
> PKIX path building failed:
> sun.security.provider.certpath.SunCertPathBuilderException: unable to find
> valid certification path to requested target
>         at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         at javax.mail.Service.connect(Service.java:288)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         at
>
> org.apache.camel.component.mail.MailConsumer.ensureIsConnected(MailConsumer.java:376)
> ~[camel-mail-2.10.1.jar:2.10.1]
>         at
> org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:82)
> ~[camel-mail-2.10.1.jar:2.10.1]
>         at
>
> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:139)
> [camel-core-2.10.1.jar:2.10.1]
>         at
>
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:91)
> [camel-core-2.10.1.jar:2.10.1]
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> [na:1.7.0_11]
>         at
> java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
> [na:1.7.0_11]
>         at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
> [na:1.7.0_11]
>         at
>
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
> [na:1.7.0_11]
>         at
>
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
> [na:1.7.0_11]
>         at
>
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> [na:1.7.0_11]
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> [na:1.7.0_11]
>         at java.lang.Thread.run(Thread.java:722) [na:1.7.0_11]
> Caused by: javax.net.ssl.SSLHandshakeException:
> sun.security.validator.ValidatorException: PKIX path building failed:
> sun.security.provider.certpath.SunCertPathBuilderException: unable to find
> valid certification path to requested target
>         at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
> ~[na:1.7.0_11]
>         at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1902)
> ~[na:1.7.0_11]
>         at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
> ~[na:1.7.0_11]
>         at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
> ~[na:1.7.0_11]
>         at
>
> sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1338)
> ~[na:1.7.0_11]
>         at
> sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:154)
> ~[na:1.7.0_11]
>         at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
> ~[na:1.7.0_11]
>         at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
> ~[na:1.7.0_11]
>         at
> sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1032)
> ~[na:1.7.0_11]
>         at
>
> sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1328)
> ~[na:1.7.0_11]
>         at
> sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882)
> ~[na:1.7.0_11]
>         at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
> ~[na:1.7.0_11]
>         at
> com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
> ~[na:1.7.0_11]
>         at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
> ~[na:1.7.0_11]
>         at
>
> com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:97)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         at com.sun.mail.iap.Response.<init>(Response.java:96)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         at
> com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:61)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         at
> com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:135)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         at
> com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:261)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         at com.sun.mail.iap.Protocol.<init>(Protocol.java:114)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         at
> com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
> ~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
>         ... 13 common frames omitted
> Caused by: sun.security.validator.ValidatorException: PKIX path building
> failed: sun.security.provider.certpath.SunCertPathBuilderException: unable
> to find valid certification path to requested target
>         at
> sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
> ~[na:1.7.0_11]
>         at
> sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
> ~[na:1.7.0_11]
>         at sun.security.validator.Validator.validate(Validator.java:260)
> ~[na:1.7.0_11]
>         at
>
> sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)
> ~[na:1.7.0_11]
>         at
>
> sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
> ~[na:1.7.0_11]
>         at
>
> sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
> ~[na:1.7.0_11]
>         at
>
> sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1320)
> ~[na:1.7.0_11]
>         ... 31 common frames omitted
> Caused by: sun.security.provider.certpath.SunCertPathBuilderException:
> unable to find valid certification path to requested target
>         at
>
> sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196)
> ~[na:1.7.0_11]
>         at
> java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
> ~[na:1.7.0_11]
>         at
> sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
> ~[na:1.7.0_11]
>         ... 37 common frames omitted
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-poll-Google-mail-inbox-for-mails-tp5738222p5738225.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: How to poll Google mail inbox for mails

Posted by Guillermo <gl...@tecsisa.com>.
Ok, i think that connecting with protocol imap (IMAP without SSL) does not
work because isn't supported by GMail. I need to use imaps (IMAP with SSL).
But in that case i still have a problem:

Consumer
Consumer[imaps://imap.gmail.com?consumer.delay=60000&delete=false&password=******&unseen=true&username=myusername%40gmail.com]
could not poll endpoint:
Endpoint[imaps://imap.gmail.com?consumer.delay=60000&delete=false&password=******&unseen=true&username=myusername%40gmail.com]
caused by: sun.security.validator.ValidatorException: PKIX path building
failed: sun.security.provider.certpath.SunCertPathBuilderException: unable
to find valid certification path to requested target
javax.mail.MessagingException: sun.security.validator.ValidatorException:
PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
	at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at javax.mail.Service.connect(Service.java:288)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at
org.apache.camel.component.mail.MailConsumer.ensureIsConnected(MailConsumer.java:376)
~[camel-mail-2.10.1.jar:2.10.1]
	at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:82)
~[camel-mail-2.10.1.jar:2.10.1]
	at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:139)
[camel-core-2.10.1.jar:2.10.1]
	at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:91)
[camel-core-2.10.1.jar:2.10.1]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
[na:1.7.0_11]
	at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
[na:1.7.0_11]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
[na:1.7.0_11]
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
[na:1.7.0_11]
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[na:1.7.0_11]
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
[na:1.7.0_11]
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
[na:1.7.0_11]
	at java.lang.Thread.run(Thread.java:722) [na:1.7.0_11]
Caused by: javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
	at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[na:1.7.0_11]
	at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1902)
~[na:1.7.0_11]
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276) ~[na:1.7.0_11]
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270) ~[na:1.7.0_11]
	at
sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1338)
~[na:1.7.0_11]
	at
sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:154)
~[na:1.7.0_11]
	at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
~[na:1.7.0_11]
	at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
~[na:1.7.0_11]
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1032)
~[na:1.7.0_11]
	at
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1328)
~[na:1.7.0_11]
	at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882)
~[na:1.7.0_11]
	at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
~[na:1.7.0_11]
	at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
~[na:1.7.0_11]
	at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
~[na:1.7.0_11]
	at
com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:97)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at com.sun.mail.iap.Response.<init>(Response.java:96)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:61)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at
com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:135)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at
com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:261)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at com.sun.mail.iap.Protocol.<init>(Protocol.java:114)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
~[javax.mail_1.1.0.0_1-4-1.jar:1.4.1]
	... 13 common frames omitted
Caused by: sun.security.validator.ValidatorException: PKIX path building
failed: sun.security.provider.certpath.SunCertPathBuilderException: unable
to find valid certification path to requested target
	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
~[na:1.7.0_11]
	at
sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
~[na:1.7.0_11]
	at sun.security.validator.Validator.validate(Validator.java:260)
~[na:1.7.0_11]
	at
sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)
~[na:1.7.0_11]
	at
sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
~[na:1.7.0_11]
	at
sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
~[na:1.7.0_11]
	at
sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1320)
~[na:1.7.0_11]
	... 31 common frames omitted
Caused by: sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target
	at
sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196)
~[na:1.7.0_11]
	at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
~[na:1.7.0_11]
	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
~[na:1.7.0_11]
	... 37 common frames omitted



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-poll-Google-mail-inbox-for-mails-tp5738222p5738225.html
Sent from the Camel - Users mailing list archive at Nabble.com.