wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes Exception while sending mail using GNU java mail library. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Exception while sending mail using GNU java mail library." Watch "Exception while sending mail using GNU java mail library." New topic
Author

Exception while sending mail using GNU java mail library.

dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Hi guys,

I've one problem while sending mail using gnu javamail library. Here is what I'm using.

I'm using JamVm (a third party java virtual machine) with GNU Classpath 0.98. And I'm also using GNU javamail library compiled with dependent GNU libraries. Now, I've written a code to send the stored EML files on the disk to the recipient. See the following code.




and I am getting following exception while sending the mail. The code is working fine with sun JVM and the javamail (not GNU javamail) library.

Exception is

Exception while sending Mail java.lang.ClassCastException: java/io/ByteArrayInputStreamjava.lang.ClassCastException: java/io/ByteArrayInputStream
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:1866)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1843)
at javax.mail.Transport.send(Transport.java:74)
at my.utilities.SendUtility.sendMail(SendUtility.java:199)
at my.utilities.SendUtility.handleReleaseRequest(SendUtility.java:70)
at my.servlets.MyServlet.doPost(MyServlet..java:129)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:638)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:720)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:199)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:145)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:139)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2460)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:119)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:410)
at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:529)
at java.lang.Thread.run(Thread.java:745)



Thanks in advance.
Dhaval.


a.k.a stalker.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41592
    
  55
I'm not too familiar the GNU JavaMail implementation, but it seems to have been abandoned years ago (and implements a correspondingly old version of Sun's JavaMail). Have you tried using Sun's implementation on JamVm?

Since the full source of GNU JavaMail is available, you could hook it up to a debugger to see what's going on.


Ping & DNS - my free Android networking tools app
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Ulf Dittmer wrote:I'm not too familiar the GNU JavaMail implementation, but it seems to have been abandoned years ago (and implements a correspondingly old version of Sun's JavaMail). Have you tried using Sun's implementation on JamVm?

Since the full source of GNU JavaMail is available, you could hook it up to a debugger to see what's going on.


Yes, I've tried sun's javamail implementations, its not working as well with GNU classpath 0.98. And that is why I bring GNU javamail implementation for my application.

BTW I will try to hookup in GNU javamail library as you suggested.

Thanks for the reply mate.

Thanks,
Dhaval
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

I think I am having problem while setting a handler for multipart. Does anybody know how to set a handler for multipart/mixed?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41592
    
  55
The JavaEnterpriseEditionFaq links to much useful material regarding JavaMail, including an extensive tutorial with code samples.
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Ulf Dittmer wrote:The JavaEnterpriseEditionFaq links to much useful material regarding JavaMail, including an extensive tutorial with code samples.


Thanks for this useful link Ulf. But I couldn't find anything regarding multipart/mixed mime type in the link.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41592
    
  55
The tutorial talks about multipart at length. The MimeMultipart javadocs go into more detail; specifically, check out the setSubType method.
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Ulf Dittmer wrote:The tutorial talks about multipart at length. The MimeMultipart javadocs go into more detail; specifically, check out the setSubType method.


Thanks for the link. I've read that link. But that link specifies javamail API. I'm using GNU javamail library. I've also seen the GNU API's and try to set handler for it. Now, I am able to send mail. But receive blank contents.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

But isn't the GNU JavaMail API the same as Sun's JavaMail API? In which case you're just looking at bugs in the GNU version. And based on what Ulf says, those bugs aren't going to be fixed unless you do it yourself.
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Paul Clapham wrote:But isn't the GNU JavaMail API the same as Sun's JavaMail API? In which case you're just looking at bugs in the GNU version. And based on what Ulf says, those bugs aren't going to be fixed unless you do it yourself.


Yeah right.. GNU javamail is same as javamail API. I think I've to find the bugs and have to fix 'em myself. :( :( :( :thumbdown:

But still if anybody finds a solution,post it here. So anybody can refer to this thread.

Thanks,
Dhaval.
 
Don't get me started about those stupid light bulbs.
 
subject: Exception while sending mail using GNU java mail library.