Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NPE in JavaMail at MailcapFile.parse() during Transport.send(), help???

1 view
Skip to first unread message

Zacharias J. Beckman

unread,
Aug 30, 2002, 2:09:56 PM8/30/02
to
A DESCRIPTION OF THE PROBLEM :
With the latest JavaMail 1.3 and JAF 1.0.2, using both JDK
1.3 and JDK 1.4, any attempt to send mail causes a
NullPointerException inside of
com.sun.activation.registries.MailcapFile.parseLine(). The
exception indicates an NPE occurred while trying to concat()
Strings.

This problem occurs consistently on most Linux boxes that
I've tried our test program on. However, it does work on
_some_ Linux boxes that (in theory) have the same basic
configuration. Clearly there must be something different,
but I can't figure out what it might be... :-(

This worked properly in a much earlier JavaMail release,
probably 1.0.x, and under an earlier JDK.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create the test SendMail program (source included below).

2. Compile the program with the latest JavaMail and JAF:
javac -classpath
/usr/local/bold/wlserver6.1/config/zbeckman/lib/mail.jar:/usr/local/bold/wlserver6.1/config/zbeckman/lib/activation.jar
SendMessage.java

3. Run it, for example, as thus:
java -classpath
/usr/local/bold/wlserver6.1/config/zbeckman/lib/mail.jar:/usr/local/bold/wlserver6.1/config/zbeckman/lib/activation.jar:.
SendMessage te...@boldsoftware.com te...@boldsoftware.com
smtp.cyberverse.com "MySubject" "MyBodyText"

I've tried this under JDK 1.3 and 1.4.


description: FULL PRODUCT VERSION :
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

FULL OPERATING SYSTEM VERSION :
RedHat Linux 7.3
Linux radogast.boldsoftware.com 2.4.2-2smp #1 SMP Sun Apr 8
20:21:34 EDT 2001 i686 unknown
glibc-2.2.4-24

Also: Tried on RedHat 7.2 and several other similar servers.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED:
An email message should be sent.

ACTUAL:
A NullPointerException is thrown from somewhere inside of
the JAF framework. Exception included below.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NullPointerException
at java.lang.String.concat(String.java:1537)
at com.sun.activation.registries.MailcapFile.parseLine(MailcapFile.java:235)
at com.sun.activation.registries.MailcapFile.parse(MailcapFile.java:197) at
com.sun.activation.registries.MailcapFile.createMailcapHash(MailcapFile.java:157)
at com.sun.activation.registries.MailcapFile.<init>(MailcapFile.java:40) at javax.activation.MailcapCommandMap.loadFile(MailcapCommandMap.java:276)
at javax.activation.MailcapCommandMap.<init>(MailcapCommandMap.java:128) at javax.activation.CommandMap.getDefaultCommandMap(CommandMap.java:44)
at javax.activation.DataHandler.getCommandMap(DataHandler.java:136)
at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:568)
at javax.activation.DataHandler.writeTo(DataHandler.java:294)
at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:222)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1065)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:1914)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1895)
at javax.mail.Transport.send(Transport.java:79)
at SendMessage.main(SendMessage.java:29)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;

public class SendMessage
{
public static final void main(String[] args)
{
try
{
if(args.length < 5)
{
System.out.println("java SendMessage" +
" fr...@domain.com t...@domain.com mailhost.domain.com" +
" subject \"mail content\"");
return;
}
Properties props = System.getProperties();
props.put("mail.smtp.host",args[2]);
Session session = Session.getDefaultInstance(props);
Message message = new MimeMessage(session);
InternetAddress from = new InternetAddress(args[0]);
InternetAddress to[] = InternetAddress.parse(args[1]);
message.setFrom(from);
message.setRecipients(Message.RecipientType.TO,to);
message.setSubject(args[3]);
message.setSentDate(new Date());
message.setText(args[4]);
Transport.send(message);
}
catch(MessagingException e)
{
System.err.println(e.getMessage());
}
}
}
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
None. All attempts to use an alternate API cause this NPE.

0 new messages