users@glassfish.java.net

problems with JavaMail Session + GMail

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Thu, 29 Jan 2009 19:37:13 +0100

how to configure JavaMail session in Glassfish in order to send
emails through GMail ??

programaticaly I can send email without any problems.. (creating
everything by code, adding the javamail jar, etc..old school)

but when I try to inject the JavaMail session and use transport in
static way, it fails...

here it is my Glassfish JavaMail configuration:
https://cejug-classifieds.dev.java.net/files/documents/8128/125099/javamail.png

and here it is the log with the error:


[#|2009-01-29T19:35:38.091+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: JavaMail version 1.4.1|#]

[#|2009-01-29T19:35:38.092+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: not loading file:
/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/javamail.providers|#]

[#|2009-01-29T19:35:38.092+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: java.io.FileNotFoundException:
/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/javamail.providers (No such
file or directory)|#]

[#|2009-01-29T19:35:38.094+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: !anyLoaded|#]

[#|2009-01-29T19:35:38.095+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: not loading resource: /META-INF/javamail.providers|#]

[#|2009-01-29T19:35:38.098+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers|#]

[#|2009-01-29T19:35:38.098+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: Tables of loaded providers|#]

[#|2009-01-29T19:35:38.098+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: Providers Listed By Class Name:
{com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun
Microsystems, Inc],
com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc],
com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun
Microsystems, Inc],
com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun
Microsystems, Inc],
com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
Microsystems, Inc],
com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
Microsystems, Inc]}|#]

[#|2009-01-29T19:35:38.098+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: Providers Listed By Protocol:
{imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun
Microsystems, Inc],
imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
Microsystems, Inc],
smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun
Microsystems, Inc],
pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
Microsystems, Inc],
pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun
Microsystems, Inc],
smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc]}|#]

[#|2009-01-29T19:35:38.099+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map|#]

[#|2009-01-29T19:35:38.099+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: !anyLoaded|#]

[#|2009-01-29T19:35:38.100+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: not loading resource: /META-INF/javamail.address.map|#]

[#|2009-01-29T19:35:38.100+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: not loading file:
/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/javamail.address.map|#]

[#|2009-01-29T19:35:38.100+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
DEBUG: java.io.FileNotFoundException:
/usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/javamail.address.map (No such
file or directory)|#]

[#|2009-01-29T19:35:38.141+0100|INFO|sun-appserver9.1|net.java.dev.cejug.classifieds.service.messaging.ClassifiedsMailerBean|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|JavaMail Session: javax.mail.Session_at_1dbc4a5|#]

[#|2009-01-29T19:35:38.213+0100|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=p:
thread-pool-1; w: 4;|
MDB: Sending Message...|#]

[#|2009-01-29T19:35:38.532+0100|SEVERE|sun-appserver9.1|net.java.dev.cejug.classifieds.service.messaging.ClassifiedsMailerBean|_ThreadID=20;_ThreadName=p:
thread-pool-1; w:
4;_RequestID=262d02df-427e-4ca2-8794-c2ca4b96bffe;|onMessage error
com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication
Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257
e20sm127127fga.43

        at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1515)
        at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1054)
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:634)
        at javax.mail.Transport.send0(Transport.java:189)
        at javax.mail.Transport.send(Transport.java:118)
        at net.java.dev.cejug.classifieds.service.messaging.ClassifiedsMailerBean.onMessage(ClassifiedsMailerBean.java:96)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:182)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSecurityManager.java:1041)
        at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:187)
        at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
        at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
        at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1111)
        at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:74)
        at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:179)
        at $Proxy170.onMessage(Unknown Source)
        at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:258)
        at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:76)
        at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
|#]