简体   繁体   中英

Spring Integration Mail Adapter Using Wrong User

We have a Spring Integration process that is using an Email Adpater to programatically read email from a GMail account. When it runs on my local PC, everything runs fine. When we deploy this to our Linux server (Linux 2.6.32-279.11.1.el6.x86_64), then the same configuration looks like it is using the server account that the application runs under and not the parameter that is configured in Spring.

We are trying to connect to mail.account@gmail.com

<mail:imap-idle-channel-adapter id="customAdapter"
      store-uri="imaps://mail.account:password@imap.gmail.com/INBOX"
      java-mail-properties="javaMailProperties"
      channel="receiveEmailChannel"
      should-delete-messages="false"
      should-mark-messages-as-read="true"
      auto-startup="true">
</mail:imap-idle-channel-adapter>

Running on my PC, I get the following from the mail.debug logging. Notice that the user is mail.account

A0 CAPABILITY
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN
A0 OK Thats all she wrote! y4if3012170qcp.27
DEBUG IMAP: AUTH: XOAUTH
DEBUG IMAP: AUTH: XOAUTH2
DEBUG IMAP: AUTH: PLAIN
DEBUG IMAP: AUTH: PLAIN-CLIENTTOKEN
DEBUG: protocolConnect login, host=imap.gmail.com, user=mail.account, password=<non-null>
A1 AUTHENTICATE PLAIN

Running on Linux, I get the following from the mail.debug logging. Notice that the user is server.account

DEBUG: trying to connect to host "imap.gmail.com", port 993, isSSL true
* OK Gimap ready for requests from 999.999.9.999 u6if3552599icy.8
A0 CAPABILITY
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN
A0 OK Thats all she wrote! u6if3552599icy.8
DEBUG IMAP: AUTH: XOAUTH
DEBUG IMAP: AUTH: XOAUTH2
DEBUG IMAP: AUTH: PLAIN
DEBUG IMAP: AUTH: PLAIN-CLIENTTOKEN
DEBUG: protocolConnect login, host=imap.gmail.com, user=server.account, password=<non-null>
DEBUG IMAP: AUTHENTICATE PLAIN command trace suppressed
DEBUG IMAP: AUTHENTICATE PLAIN command result: A1 NO Invalid credentials u6if3552599icy.8

This is a Grails app and we have a build management system in place to do the builds and deploys, so I'm fairly confident that the jar files and configuration should be the same.

I'm at the end of my rope trying to track this down. Anyone ever experience this before?

This wound up being an issue with the Grails packaging and distribution of the war. There is still more work and investigation needed for our final solution, but I think that may wind up being a separate StackOverflow question.

The basic issue was that when Grails creates the WAR, it includes jar files for several servlet containers, including Geronimo. The Geronimo jars were not present, but were in the WAR package. For the deployed version of the WAR, we stopped the app, went to WEB-INF/lib and removed geronimo-javamail_1.4_spec-1.7.1.jar , and restarted the app. Everything works great now. The authentication in Geronimo must be different/broken.

Now we just need to find out how to exclude the Geronimo jars from our distribution.


The final culprit was the ws-client plugin that was included in application.properties . Once this was removed, we no longer had any geronimo-*.jar files included in the prroject.

plugins.ws-client=1.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM