dcsimg
NullPointerException in constructor of MimeMessage
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jo_Ritter
Posted On:   Thursday, May 17, 2001 07:58 AM

Environment: Tomcat 3.1, JDK 1.2.2, JavaMail 1.2 The constructor of MimeMessage always generates a NullPointerException. This is my code: // Properties Properties mailProps = new Properties(); mailProps.put("mail.smtp.host", "krpcmail.braunag.de"); Session mailSession = Session.getDefaultInstance(mailProps, null); mailSession.setDebug(true); // Addresses InternetAddress[] toAddrs = new InternetAddress[iNum]; for (int i=0; i toAddrs[i] = new InternetAddress((String) vecAddresses.elementAt(i)); } InternetAddress fromAddr = new Internet   More>>

Environment: Tomcat 3.1, JDK 1.2.2, JavaMail 1.2

The constructor of MimeMessage always generates a NullPointerException. This is my code:





// Properties

Properties mailProps = new Properties();

mailProps.put("mail.smtp.host", "krpcmail.braunag.de");

Session mailSession = Session.getDefaultInstance(mailProps, null);

mailSession.setDebug(true);

// Addresses

InternetAddress[] toAddrs = new InternetAddress[iNum];

for (int i=0; i

toAddrs[i] = new InternetAddress((String) vecAddresses.elementAt(i));

}

InternetAddress fromAddr = new InternetAddress("TPIT Support Notification" + " <" + strFromAddress + ">");

// Create and initialize message

Message msg = null;

try {

msg = new MimeMessage(mailSession);

} catch (NullPointerException e) {

// constructor of MimeMessage always generated a NullPointerException

}



Does anybody have an idea why this happens?

   <<Less

Re: NullPointerException in constructor of MimeMessage

Posted By:   John_Zukowski  
Posted On:   Thursday, May 17, 2001 04:46 PM

Clean up the example to remove what's unnecessary before the call. Make sure your argument isn't null sent into the method.

Re: NullPointerException in constructor of MimeMessage

Posted By:   Luigi_Viggiano  
Posted On:   Thursday, May 17, 2001 03:13 PM

Without any specific knowledge on JavaMail I try to answer.

you can guess where NullPointerException is raised checking the stacktrace.
Looking at the code (but not knowing Session class - I think from javamail api), the NullPointerException can happen if

Session.getDefaultInstance(mailProps, null);


returns null setting mailSession to null; and calling

mailSession.setDebug(true);

you get the exception.


pls. check value of mailSession after getDefaultInstance invokation.
About | Sitemap | Contact