• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Mail - UnsupportedDataTypeException

 
sumanth kadaba
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

jdk version : jdk1.6
Mail Api : javamail-1.4.jar
IDE : Eclipse Ganymede

I made a small application to send Emails in plain/html format along with attachments.
The application worked well when I referenced javamail-1.4.jar.

I then bundled my application with javamail-1.4.jar into a new jar file using ant 1.7.

To test this jar I created a test java file and referenced the new jar.
I got this exception while trying to send the mail.
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=_Part_0_9510769.1245565477000"

I read about this but could not get a clear picture of what I was doing wrong.

Any comments?

Thanks in advance.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See here. I suspect you're having the same problem since you're putting the mail jar into your own jar.
 
sumanth kadaba
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

Thanks for the reply. I did go through this link before. Help me understand this.


JAF uses the context class loader to load classes. If that fails,
it uses the class loader that loaded the JAF classes.

When JAF is packaged with the application, the JAF classes are
loaded by the same class loader as the other application classes,
so even if the context class loader isn't set JAF can find the
other application classes.

When JAF is part of the JDK, the JAF classes are loaded by the
system class loader. Without the context class loader being set,
JAF has no way to find the appropriate class loader to load
application classes.

(Since JavaMail is packaged with the application, the JavaMail
class are treated the same as application classes.)


The class loader concept is fine here but am not 100% sure that I have understood this.



A workaround is to set the boot class path to include mail.jar.

I have used javamail-1.4.jar. Also, I have not directly added the jar[Jar inside a Jar], I have added the source/ class files. Now the link says that add mail.jar into the class path.
The main reason I tried to bundle this application was to not have two separate jars i.e my sampleApp.jar and javamail-1.4.jar and rather have one jar containing the two jars source. My application works fine if I set the classpath, but as I told you above the purpose is not quite solved.

Also I went through the source of javamail-1.4.jar and mail.jar. I couldn't find much difference except for few enhancements in the javamail-1.4.jar.

Please let me know.

Am I doing something feasible?

Thanks for your time.


David Newton wrote:See here. I suspect you're having the same problem since you're putting the mail jar into your own jar.


 
sumanth kadaba
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:See here. I suspect you're having the same problem since you're putting the mail jar into your own jar.


Hi David,

The problem was with the mailcap. This was not included by the ant script I had written. The ANT Script was the culprit. The below paragraph enlightened me.


Mailcap file search order:
The MailcapCommandMap looks in various places in the user's system for mailcap file entries. When requests are made to search for commands in the MailcapCommandMap, it searches mailcap files in the following order:

1. Programatically added entries to the MailcapCommandMap instance.
2. The file .mailcap in the user's home directory.
3. The file <java.home>/lib/mailcap.
4. The file or resources named META-INF/mailcap.
5. The file or resource named META-INF/mailcap.default (usually found only in the activation.jar file).


I wold like the moderator to close this thread officially, unless there s someone who can shed some light on the earlier discussed post.

Thanks David...

Cheers,
Kadaba
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic