You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Alfred Hiebl (JIRA)" <ji...@apache.org> on 2011/03/08 17:09:59 UTC

[jira] Created: (CAMEL-3769) Mail component issue with starttls option

Mail component issue with starttls option
-----------------------------------------

                 Key: CAMEL-3769
                 URL: https://issues.apache.org/jira/browse/CAMEL-3769
             Project: Camel
          Issue Type: Bug
          Components: camel-mail
    Affects Versions: 2.6.0
            Reporter: Alfred Hiebl


The problem occurs when I read from a pop3 endpoint and send to an smtp endpoint in the same camel context with the mail.pop3.starttls.enable=true and mail.smtp.starttls.enable=true options.

Required Java options for starttls are set:
-Djavax.net.ssl.trustStore=D:\test\xxx.jks
-Djavax.net.ssl.trustStorePassword=yyy


When I only configure one of either route, everything works fine. When I configure both, I get the following exception:

AUTH LOGIN
C: STAT
530 Must issue STARTTLS command first
STARTTLS
S: +OK 0 0
C: NOOP
220 begin TLS negotiation
S: +OK
C: RSET
S: +OK
C: QUIT
AUTH LOGIN
S: +OK POP3 server closing connection
503 wrong state for AUTH command
2011-03-03 10:08:36,797 [foo] ERROR DefaultErrorHandler - Failed delivery for exchangeId: ID-E6500-ahi-61446-1299143304838-0-2. Exhausted after delivery attempt: 1 caught: org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command

org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command

        at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:392)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:355)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:44)[camel-mail-2.6.0.jar:2.6.0]
        at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:299)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:125)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.RoutePolicyProcessor.process(RoutePolicyProcessor.java:75)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:104)[camel-core-2.6.0.jar:2.6.0]
        at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)[camel-core-2.6.0.jar:2.6.0]
        at java.util.TimerThread.mainLoop(Unknown Source)[:1.5.0_22]
        at java.util.TimerThread.run(Unknown Source)[:1.5.0_22]



The problem seems to be in org.apache.camel.component.mail.MailConfiguration.createJavaMailSender() where it uses the same mail session for both connection; see Session.getDefaultInstance below

        if (session != null) {
            answer.setSession(session);
        } else {
            // use our authenticator that does no live user interaction but returns the already configured username and password
            Session session;
            try {
                session = Session.getDefaultInstance(answer.getJavaMailProperties(), getAuthenticator());
            } catch (Throwable t) {
                // fallback as default instance may not be allowed on some systems
                session = Session.getInstance(answer.getJavaMailProperties(), getAuthenticator());
            }
            answer.setSession(session);
        }


This is because getDefaultInstance creates a Session object the first time it is called. Then it caches that Session and returns it for all subsequent calls. It also ignores the new and different properties for the second route.


See also http://camel.465427.n5.nabble.com/Mail-component-with-starttls-td3409505.html 


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Commented: (CAMEL-3769) Mail component issue with starttls option

Posted by "Alfred Hiebl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004019#comment-13004019 ] 

Alfred Hiebl commented on CAMEL-3769:
-------------------------------------

I suggest to change this section of the code to always use getInstance instead of getDefaultInstance.


        if (session != null) {
            answer.setSession(session);
        } else {
            // use our authenticator that does no live user interaction but returns the already configured username and password
            Session session = Session.getInstance(answer.getJavaMailProperties(), getAuthenticator());
            // sets the debug mode of the underlying mail framework
            session.setDebug(debugMode);
            answer.setSession(session);
        }

> Mail component issue with starttls option
> -----------------------------------------
>
>                 Key: CAMEL-3769
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3769
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mail
>    Affects Versions: 2.6.0
>            Reporter: Alfred Hiebl
>
> The problem occurs when I read from a pop3 endpoint and send to an smtp endpoint in the same camel context with the mail.pop3.starttls.enable=true and mail.smtp.starttls.enable=true options.
> Required Java options for starttls are set:
> -Djavax.net.ssl.trustStore=D:\test\xxx.jks
> -Djavax.net.ssl.trustStorePassword=yyy
> When I only configure one of either route, everything works fine. When I configure both, I get the following exception:
> AUTH LOGIN
> C: STAT
> 530 Must issue STARTTLS command first
> STARTTLS
> S: +OK 0 0
> C: NOOP
> 220 begin TLS negotiation
> S: +OK
> C: RSET
> S: +OK
> C: QUIT
> AUTH LOGIN
> S: +OK POP3 server closing connection
> 503 wrong state for AUTH command
> 2011-03-03 10:08:36,797 [foo] ERROR DefaultErrorHandler - Failed delivery for exchangeId: ID-E6500-ahi-61446-1299143304838-0-2. Exhausted after delivery attempt: 1 caught: org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
> org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
>         at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:392)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:355)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:44)[camel-mail-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:299)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:125)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RoutePolicyProcessor.process(RoutePolicyProcessor.java:75)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)[camel-core-2.6.0.jar:2.6.0]
>         at java.util.TimerThread.mainLoop(Unknown Source)[:1.5.0_22]
>         at java.util.TimerThread.run(Unknown Source)[:1.5.0_22]
> The problem seems to be in org.apache.camel.component.mail.MailConfiguration.createJavaMailSender() where it uses the same mail session for both connection; see Session.getDefaultInstance below
>         if (session != null) {
>             answer.setSession(session);
>         } else {
>             // use our authenticator that does no live user interaction but returns the already configured username and password
>             Session session;
>             try {
>                 session = Session.getDefaultInstance(answer.getJavaMailProperties(), getAuthenticator());
>             } catch (Throwable t) {
>                 // fallback as default instance may not be allowed on some systems
>                 session = Session.getInstance(answer.getJavaMailProperties(), getAuthenticator());
>             }
>             answer.setSession(session);
>         }
> This is because getDefaultInstance creates a Session object the first time it is called. Then it caches that Session and returns it for all subsequent calls. It also ignores the new and different properties for the second route.
> See also http://camel.465427.n5.nabble.com/Mail-component-with-starttls-td3409505.html 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Updated: (CAMEL-3769) Mail component issue with starttls option

Posted by "Alfred Hiebl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alfred Hiebl updated CAMEL-3769:
--------------------------------

    Attachment: MailConfiguration.java

Changes are highlighted with kex word "BUG FIX"

> Mail component issue with starttls option
> -----------------------------------------
>
>                 Key: CAMEL-3769
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3769
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mail
>    Affects Versions: 2.6.0
>            Reporter: Alfred Hiebl
>         Attachments: MailConfiguration.java
>
>
> The problem occurs when I read from a pop3 endpoint and send to an smtp endpoint in the same camel context with the mail.pop3.starttls.enable=true and mail.smtp.starttls.enable=true options.
> Required Java options for starttls are set:
> -Djavax.net.ssl.trustStore=D:\test\xxx.jks
> -Djavax.net.ssl.trustStorePassword=yyy
> When I only configure one of either route, everything works fine. When I configure both, I get the following exception:
> AUTH LOGIN
> C: STAT
> 530 Must issue STARTTLS command first
> STARTTLS
> S: +OK 0 0
> C: NOOP
> 220 begin TLS negotiation
> S: +OK
> C: RSET
> S: +OK
> C: QUIT
> AUTH LOGIN
> S: +OK POP3 server closing connection
> 503 wrong state for AUTH command
> 2011-03-03 10:08:36,797 [foo] ERROR DefaultErrorHandler - Failed delivery for exchangeId: ID-E6500-ahi-61446-1299143304838-0-2. Exhausted after delivery attempt: 1 caught: org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
> org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
>         at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:392)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:355)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:44)[camel-mail-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:299)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:125)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RoutePolicyProcessor.process(RoutePolicyProcessor.java:75)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)[camel-core-2.6.0.jar:2.6.0]
>         at java.util.TimerThread.mainLoop(Unknown Source)[:1.5.0_22]
>         at java.util.TimerThread.run(Unknown Source)[:1.5.0_22]
> The problem seems to be in org.apache.camel.component.mail.MailConfiguration.createJavaMailSender() where it uses the same mail session for both connection; see Session.getDefaultInstance below
>         if (session != null) {
>             answer.setSession(session);
>         } else {
>             // use our authenticator that does no live user interaction but returns the already configured username and password
>             Session session;
>             try {
>                 session = Session.getDefaultInstance(answer.getJavaMailProperties(), getAuthenticator());
>             } catch (Throwable t) {
>                 // fallback as default instance may not be allowed on some systems
>                 session = Session.getInstance(answer.getJavaMailProperties(), getAuthenticator());
>             }
>             answer.setSession(session);
>         }
> This is because getDefaultInstance creates a Session object the first time it is called. Then it caches that Session and returns it for all subsequent calls. It also ignores the new and different properties for the second route.
> See also http://camel.465427.n5.nabble.com/Mail-component-with-starttls-td3409505.html 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Resolved: (CAMEL-3769) Mail component issue with starttls option

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-3769.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.7.0

trunk: 1079708.

> Mail component issue with starttls option
> -----------------------------------------
>
>                 Key: CAMEL-3769
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3769
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mail
>    Affects Versions: 2.6.0
>            Reporter: Alfred Hiebl
>            Assignee: Claus Ibsen
>             Fix For: 2.7.0
>
>         Attachments: MailConfiguration.java
>
>
> The problem occurs when I read from a pop3 endpoint and send to an smtp endpoint in the same camel context with the mail.pop3.starttls.enable=true and mail.smtp.starttls.enable=true options.
> Required Java options for starttls are set:
> -Djavax.net.ssl.trustStore=D:\test\xxx.jks
> -Djavax.net.ssl.trustStorePassword=yyy
> When I only configure one of either route, everything works fine. When I configure both, I get the following exception:
> AUTH LOGIN
> C: STAT
> 530 Must issue STARTTLS command first
> STARTTLS
> S: +OK 0 0
> C: NOOP
> 220 begin TLS negotiation
> S: +OK
> C: RSET
> S: +OK
> C: QUIT
> AUTH LOGIN
> S: +OK POP3 server closing connection
> 503 wrong state for AUTH command
> 2011-03-03 10:08:36,797 [foo] ERROR DefaultErrorHandler - Failed delivery for exchangeId: ID-E6500-ahi-61446-1299143304838-0-2. Exhausted after delivery attempt: 1 caught: org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
> org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
>         at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:392)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:355)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:44)[camel-mail-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:299)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:125)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RoutePolicyProcessor.process(RoutePolicyProcessor.java:75)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)[camel-core-2.6.0.jar:2.6.0]
>         at java.util.TimerThread.mainLoop(Unknown Source)[:1.5.0_22]
>         at java.util.TimerThread.run(Unknown Source)[:1.5.0_22]
> The problem seems to be in org.apache.camel.component.mail.MailConfiguration.createJavaMailSender() where it uses the same mail session for both connection; see Session.getDefaultInstance below
>         if (session != null) {
>             answer.setSession(session);
>         } else {
>             // use our authenticator that does no live user interaction but returns the already configured username and password
>             Session session;
>             try {
>                 session = Session.getDefaultInstance(answer.getJavaMailProperties(), getAuthenticator());
>             } catch (Throwable t) {
>                 // fallback as default instance may not be allowed on some systems
>                 session = Session.getInstance(answer.getJavaMailProperties(), getAuthenticator());
>             }
>             answer.setSession(session);
>         }
> This is because getDefaultInstance creates a Session object the first time it is called. Then it caches that Session and returns it for all subsequent calls. It also ignores the new and different properties for the second route.
> See also http://camel.465427.n5.nabble.com/Mail-component-with-starttls-td3409505.html 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Assigned: (CAMEL-3769) Mail component issue with starttls option

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-3769:
----------------------------------

    Assignee: Claus Ibsen

> Mail component issue with starttls option
> -----------------------------------------
>
>                 Key: CAMEL-3769
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3769
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mail
>    Affects Versions: 2.6.0
>            Reporter: Alfred Hiebl
>            Assignee: Claus Ibsen
>         Attachments: MailConfiguration.java
>
>
> The problem occurs when I read from a pop3 endpoint and send to an smtp endpoint in the same camel context with the mail.pop3.starttls.enable=true and mail.smtp.starttls.enable=true options.
> Required Java options for starttls are set:
> -Djavax.net.ssl.trustStore=D:\test\xxx.jks
> -Djavax.net.ssl.trustStorePassword=yyy
> When I only configure one of either route, everything works fine. When I configure both, I get the following exception:
> AUTH LOGIN
> C: STAT
> 530 Must issue STARTTLS command first
> STARTTLS
> S: +OK 0 0
> C: NOOP
> 220 begin TLS negotiation
> S: +OK
> C: RSET
> S: +OK
> C: QUIT
> AUTH LOGIN
> S: +OK POP3 server closing connection
> 503 wrong state for AUTH command
> 2011-03-03 10:08:36,797 [foo] ERROR DefaultErrorHandler - Failed delivery for exchangeId: ID-E6500-ahi-61446-1299143304838-0-2. Exhausted after delivery attempt: 1 caught: org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
> org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
>         at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:392)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:355)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:44)[camel-mail-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:299)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:125)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RoutePolicyProcessor.process(RoutePolicyProcessor.java:75)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)[camel-core-2.6.0.jar:2.6.0]
>         at java.util.TimerThread.mainLoop(Unknown Source)[:1.5.0_22]
>         at java.util.TimerThread.run(Unknown Source)[:1.5.0_22]
> The problem seems to be in org.apache.camel.component.mail.MailConfiguration.createJavaMailSender() where it uses the same mail session for both connection; see Session.getDefaultInstance below
>         if (session != null) {
>             answer.setSession(session);
>         } else {
>             // use our authenticator that does no live user interaction but returns the already configured username and password
>             Session session;
>             try {
>                 session = Session.getDefaultInstance(answer.getJavaMailProperties(), getAuthenticator());
>             } catch (Throwable t) {
>                 // fallback as default instance may not be allowed on some systems
>                 session = Session.getInstance(answer.getJavaMailProperties(), getAuthenticator());
>             }
>             answer.setSession(session);
>         }
> This is because getDefaultInstance creates a Session object the first time it is called. Then it caches that Session and returns it for all subsequent calls. It also ignores the new and different properties for the second route.
> See also http://camel.465427.n5.nabble.com/Mail-component-with-starttls-td3409505.html 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Issue Comment Edited: (CAMEL-3769) Mail component issue with starttls option

Posted by "Alfred Hiebl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004019#comment-13004019 ] 

Alfred Hiebl edited comment on CAMEL-3769 at 3/8/11 4:12 PM:
-------------------------------------------------------------

I suggest to change this section of the code to always use getInstance instead of getDefaultInstance.

{code}
        if (session != null) {
            answer.setSession(session);
        } else {
            // use our authenticator that does no live user interaction but returns the already configured username and password
            Session session = Session.getInstance(answer.getJavaMailProperties(), getAuthenticator());
            // sets the debug mode of the underlying mail framework
            session.setDebug(debugMode);
            answer.setSession(session);
        }
{code}

      was (Author: ahiebl):
    I suggest to change this section of the code to always use getInstance instead of getDefaultInstance.


        if (session != null) {
            answer.setSession(session);
        } else {
            // use our authenticator that does no live user interaction but returns the already configured username and password
            Session session = Session.getInstance(answer.getJavaMailProperties(), getAuthenticator());
            // sets the debug mode of the underlying mail framework
            session.setDebug(debugMode);
            answer.setSession(session);
        }
  
> Mail component issue with starttls option
> -----------------------------------------
>
>                 Key: CAMEL-3769
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3769
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mail
>    Affects Versions: 2.6.0
>            Reporter: Alfred Hiebl
>
> The problem occurs when I read from a pop3 endpoint and send to an smtp endpoint in the same camel context with the mail.pop3.starttls.enable=true and mail.smtp.starttls.enable=true options.
> Required Java options for starttls are set:
> -Djavax.net.ssl.trustStore=D:\test\xxx.jks
> -Djavax.net.ssl.trustStorePassword=yyy
> When I only configure one of either route, everything works fine. When I configure both, I get the following exception:
> AUTH LOGIN
> C: STAT
> 530 Must issue STARTTLS command first
> STARTTLS
> S: +OK 0 0
> C: NOOP
> 220 begin TLS negotiation
> S: +OK
> C: RSET
> S: +OK
> C: QUIT
> AUTH LOGIN
> S: +OK POP3 server closing connection
> 503 wrong state for AUTH command
> 2011-03-03 10:08:36,797 [foo] ERROR DefaultErrorHandler - Failed delivery for exchangeId: ID-E6500-ahi-61446-1299143304838-0-2. Exhausted after delivery attempt: 1 caught: org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
> org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
>         at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:392)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:355)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:44)[camel-mail-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:299)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:125)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RoutePolicyProcessor.process(RoutePolicyProcessor.java:75)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)[camel-core-2.6.0.jar:2.6.0]
>         at java.util.TimerThread.mainLoop(Unknown Source)[:1.5.0_22]
>         at java.util.TimerThread.run(Unknown Source)[:1.5.0_22]
> The problem seems to be in org.apache.camel.component.mail.MailConfiguration.createJavaMailSender() where it uses the same mail session for both connection; see Session.getDefaultInstance below
>         if (session != null) {
>             answer.setSession(session);
>         } else {
>             // use our authenticator that does no live user interaction but returns the already configured username and password
>             Session session;
>             try {
>                 session = Session.getDefaultInstance(answer.getJavaMailProperties(), getAuthenticator());
>             } catch (Throwable t) {
>                 // fallback as default instance may not be allowed on some systems
>                 session = Session.getInstance(answer.getJavaMailProperties(), getAuthenticator());
>             }
>             answer.setSession(session);
>         }
> This is because getDefaultInstance creates a Session object the first time it is called. Then it caches that Session and returns it for all subsequent calls. It also ignores the new and different properties for the second route.
> See also http://camel.465427.n5.nabble.com/Mail-component-with-starttls-td3409505.html 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Commented: (CAMEL-3769) Mail component issue with starttls option

Posted by "Alfred Hiebl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004027#comment-13004027 ] 

Alfred Hiebl commented on CAMEL-3769:
-------------------------------------

At least in my tests, the debugMode=true did not work either. I think this is beacuse 

{code}
// sets the debug mode of the underlying mail framework
answer.getSession().setDebug(debugMode);
{code}

creates a Session and sets the debug option for this session object. In the next few line the JavaMailProperties are set

{code}
answer.setJavaMailProperties()
{code}

which actually resets the Session object in JavaMailSenderImpl answer to null.


> Mail component issue with starttls option
> -----------------------------------------
>
>                 Key: CAMEL-3769
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3769
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mail
>    Affects Versions: 2.6.0
>            Reporter: Alfred Hiebl
>
> The problem occurs when I read from a pop3 endpoint and send to an smtp endpoint in the same camel context with the mail.pop3.starttls.enable=true and mail.smtp.starttls.enable=true options.
> Required Java options for starttls are set:
> -Djavax.net.ssl.trustStore=D:\test\xxx.jks
> -Djavax.net.ssl.trustStorePassword=yyy
> When I only configure one of either route, everything works fine. When I configure both, I get the following exception:
> AUTH LOGIN
> C: STAT
> 530 Must issue STARTTLS command first
> STARTTLS
> S: +OK 0 0
> C: NOOP
> 220 begin TLS negotiation
> S: +OK
> C: RSET
> S: +OK
> C: QUIT
> AUTH LOGIN
> S: +OK POP3 server closing connection
> 503 wrong state for AUTH command
> 2011-03-03 10:08:36,797 [foo] ERROR DefaultErrorHandler - Failed delivery for exchangeId: ID-E6500-ahi-61446-1299143304838-0-2. Exhausted after delivery attempt: 1 caught: org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
> org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 503 wrong state for AUTH command
>         at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:392)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:355)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344)[org.springframework.context.support-3.0.5.RELEASE.jar:3.0.5.RELEASE]
>         at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:44)[camel-mail-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:299)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:125)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.RoutePolicyProcessor.process(RoutePolicyProcessor.java:75)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:104)[camel-core-2.6.0.jar:2.6.0]
>         at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)[camel-core-2.6.0.jar:2.6.0]
>         at java.util.TimerThread.mainLoop(Unknown Source)[:1.5.0_22]
>         at java.util.TimerThread.run(Unknown Source)[:1.5.0_22]
> The problem seems to be in org.apache.camel.component.mail.MailConfiguration.createJavaMailSender() where it uses the same mail session for both connection; see Session.getDefaultInstance below
>         if (session != null) {
>             answer.setSession(session);
>         } else {
>             // use our authenticator that does no live user interaction but returns the already configured username and password
>             Session session;
>             try {
>                 session = Session.getDefaultInstance(answer.getJavaMailProperties(), getAuthenticator());
>             } catch (Throwable t) {
>                 // fallback as default instance may not be allowed on some systems
>                 session = Session.getInstance(answer.getJavaMailProperties(), getAuthenticator());
>             }
>             answer.setSession(session);
>         }
> This is because getDefaultInstance creates a Session object the first time it is called. Then it caches that Session and returns it for all subsequent calls. It also ignores the new and different properties for the second route.
> See also http://camel.465427.n5.nabble.com/Mail-component-with-starttls-td3409505.html 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira