This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 108425 - JavaMail res injection / sendMail() in servlet got invalid addr
Summary: JavaMail res injection / sendMail() in servlet got invalid addr
Status: RESOLVED WORKSFORME
Alias: None
Product: serverplugins
Classification: Unclassified
Component: Sun Appserver 9 (show other bugs)
Version: 6.x
Hardware: Sun Solaris
: P3 blocker (vote)
Assignee: Nitya Doraisamy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-28 15:33 UTC by nouar38
Modified: 2007-08-24 17:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
added the servlet code (3.00 KB, text/plain)
2007-06-28 15:37 UTC, nouar38
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nouar38 2007-06-28 15:33:17 UTC
NB 200706270000 & GF v2 52.

Got exception while accessing a JavaMail Resource injected within a Servlet (calling the sendMail method)
in a Web application.

** create a New web application
** add a JavaMail resource with default values in wizard: mail/mySession

<mail-resource debug="true" enabled="true" from="testnb@gamay-03.france.sun.com" host="gamay-03.france.sun.com"
jndi-name="mail/mySession" object-type="user" store-protocol="imap" store-protocol-class="com.sun.mail.imap.IMAPStore"
transport-protocol="smtp" transport-protocol-class="com.sun.mail.smtp.SMTPTransport" user="testnb">
    <description>nouar conf</description>
</mail-resource>

** add a servlet (NewServlet) inside the project within a source package <> default.
** in Servlet code: Add the previous created resource
in editor: click right and in "Enterprise Resources" choose "Send an Email" and give the jdni-name = mail/mySession

** verify in code: that @Resource is done + the sendMail method + the needed imports: ok


** build/"Undeploy & Deploy" the web app: OK
** Access the Servlet page: http://localhost:8080/WebApplication6/NewServlet
got the exception message added in the Servlet code when sendMail method is called.

"Got exception in sendMail method Invalid Addresses"

PING gamay-03.france.sun.com: 56 data bytes
64 bytes from gamay-03 (129.157.201.114): icmp_seq=0. time=0. ms

will join the code of the servlet.

Output-server can see:
<<<

Added Resource Type: mail-resource
ADM1041:Sent the event to instance:[ResourceDeployEvent -- reference-added mail/mail/mySession]
CORE5004: Resource Deployed: [mail:mail/mySession].
DEBUG: JavaMail version 1.4.1ea-SNAPSHOT
DEBUG: not loading file: /usr/jdk/instances/jdk1.6.0/jre/lib/javamail.providers
DEBUG: java.io.FileNotFoundException: /usr/jdk/instances/jdk1.6.0/jre/lib/javamail.providers (No such file or directory)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
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]}
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]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: not loading file: /usr/jdk/instances/jdk1.6.0/jre/lib/javamail.address.map
DEBUG: java.io.FileNotFoundException: /usr/jdk/instances/jdk1.6.0/jre/lib/javamail.address.map (No such file or directory)
ADM1041:Sent the event to instance:[ResourceDeployEvent -- reference-removed null/mail/mySession]
CORE5006: Resource UnDeployed: [mail:mail/mySession].
deployed with moduleid = WebApplication6
Added Resource Type: mail-resource
ADM1041:Sent the event to instance:[ResourceDeployEvent -- reference-added mail/mail/mySession]
CORE5004: Resource Deployed: [mail:mail/mySession].

>>>
Comment 1 nouar38 2007-06-28 15:37:07 UTC
Created attachment 44529 [details]
added the servlet code
Comment 2 Nitya Doraisamy 2007-06-28 18:18:56 UTC
This appears to be an application error. The log message indicates that the ping of the address failed.
PING gamay-03.france.sun.com: 56 data bytes
64 bytes from gamay-03 (129.157.201.114): icmp_seq=0. time=0. ms

Also, the server has error messages indicating that it could not load javamail.address.map

Have to investigate to see what are the requirements for using JavaMail in an app. Lowering to P3 as it is most
likely a configuration issue and nothing that the plugin or IDE is doing wrong
Comment 3 Nitya Doraisamy 2007-07-26 03:23:31 UTC
Cannot reproduce exception. I think the defined mail resource is wrong. Following is snippet on creating a mail 
resource from the EE tutorial,

Creating a Mail Session
To create a mail session in the Application Server using the Admin Console, follow these steps:
   1. Open the URL http://localhost:4848/asadmin in a browser.
   2. Select the JavaMail Sessions node.
   3. Click New.
   4. Type mail/MySession in the JNDI Name field.
   5. Type the name of the host running your mail server in the Mail Host field.
   6. Type the destination email address in the Default User field.
   7. Type your email address in the Default Return Address field.
   8. Click OK.
   9. Note that mail/MySession is listed under the JavaMail Sessions node.

Please reopen if you still see the issue
Comment 4 nouar38 2007-08-24 17:16:55 UTC
NB 6.0 20070820 & GF v2 b58c on solaris-sparc:
was able to receive the mail sent to my desktop as Mail server and to myself as a valid user
each time accessing the servlet.
I've created the java mail resource with the wizard in IDE.
thanks for investigating.