Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception while sending mail using GNU java mail library.

 
dhaval yoganandi
Ranch Hand
Posts: 35
Android Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
dhaval yoganandi
Ranch Hand
Posts: 35
Android Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
Android Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JavaEnterpriseEditionFaq links to much useful material regarding JavaMail, including an extensive tutorial with code samples.
 
dhaval yoganandi
Ranch Hand
Posts: 35
Android Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The tutorial talks about multipart at length. The MimeMultipart javadocs go into more detail; specifically, check out the setSubType method.
 
dhaval yoganandi
Ranch Hand
Posts: 35
Android Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
Android Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic