开发者

Javax mail with Lift framework

I'm having a strange issue.

I deploy my webapp to the server (jetty 7.4.3.v20110701), and everything (including mai开发者_高级运维ler) seem to be working fine. Debugging info (got with -Djavax.activation.debug=true) for sending an email looks like this:

MailcapCommandMap: createDataContentHandler for text/html
  search DB #0
    got content-handler
      class com.sun.mail.handlers.text_html
INFO  [qtp1699297250-32] net.liftweb.util.TimeHelpers.info[195] - Service request (GET) /reservation/276 returned 200, took 264 Milliseconds
INFO  [qtp1699297250-34] net.liftweb.util.TimeHelpers.info[195] - Service request (GET) /ajax_request/liftAjax.js returned 200, took 9 Milliseconds
MailcapCommandMap: createDataContentHandler for multipart/alternative
  search DB #0
    got content-handler
      class com.sun.mail.handlers.multipart_mixed

But then suddenly, out of nowhere the code just stops working:

Can't load DCH com.sun.mail.handlers.multipart_mixed; Exception: 
java.lang.ClassNotFoundException: com/sun/mail/handlers/multipart_mixed
  search DB #1
  search DB #2
  search DB #3
  search fallback DB #0
  search fallback DB #1
    got content-handler
      class com.sun.mail.handlers.multipart_mixed
Can't load DCH com.sun.mail.handlers.multipart_mixed; Exception: java.lang.ClassNotFoundException: com/sun/mail/handlers/multipart_mixed
  search fallback DB #2
    got content-handler
      class com.sun.mail.handlers.multipart_mixed
Can't load DCH com.sun.mail.handlers.multipart_mixed; Exception: java.lang.ClassNotFoundException: com/sun/mail/handlers/multipart_mixed
  search fallback DB #3
ERROR [pool-3-thread-13] net.liftweb.util.MailerImpl.error[239] - Couldn't send mail
javax.mail.MessagingException: IOException while sending message
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1141) ~[mail-1.4.4.jar:1.4.4]
    at javax.mail.Transport.send0(Transport.java:189) ~[mail-1.4.1.jar:1.4.1]
    at javax.mail.Transport.send(Transport.java:118) ~[mail-1.4.1.jar:1.4.1]
    at net.liftweb.util.MailerImpl$$anon$1$$anonfun$$init$$1.apply(Mailer.scala:180) ~[lift-util_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.util.MailerImpl$$anon$1$$anonfun$$init$$1.apply(Mailer.scala:180) ~[lift-util_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.util.MailerImpl$class.performTransportSend(Mailer.scala:174) ~[lift-util_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.util.Mailer$.performTransportSend(Mailer.scala:31) ~[lift-util_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.util.MailerImpl$class.msgSendImpl(Mailer.scala:276) ~[lift-util_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.util.Mailer$.msgSendImpl(Mailer.scala:31) ~[lift-util_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.util.MailerImpl$MsgSender$$anonfun$messageHandler$1.apply(Mailer.scala:158) [lift-util_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.util.MailerImpl$MsgSender$$anonfun$messageHandler$1.apply(Mailer.scala:155) [lift-util_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.actor.SpecializedLiftActor$class.execTranslate(LiftActor.scala:321) [lift-actor_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.util.MailerImpl$MsgSender.execTranslate(Mailer.scala:154) [lift-util_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.actor.SpecializedLiftActor$class.net$liftweb$actor$SpecializedLiftActor$$proc2(LiftActor.scala:289) [lift-actor_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.actor.SpecializedLiftActor$$anonfun$net$liftweb$actor$SpecializedLiftActor$$processMailbox$1.apply(LiftActor.scala:210) [lift-actor_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.actor.SpecializedLiftActor$$anonfun$net$liftweb$actor$SpecializedLiftActor$$processMailbox$1.apply(LiftActor.scala:210) [lift-actor_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.actor.SpecializedLiftActor$class.around(LiftActor.scala:224) [lift-actor_2.9.0-1-2.4-M1.jar:2.4-M1]
        at net.liftweb.util.MailerImpl$MsgSender.around(Mailer.scala:154) [lift-util_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.actor.SpecializedLiftActor$class.net$liftweb$actor$SpecializedLiftActor$$processMailbox(LiftActor.scala:209) [lift-actor_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.actor.SpecializedLiftActor$$anonfun$2$$anonfun$apply$mcV$sp$1.apply$mcV$sp(LiftActor.scala:173) [lift-actor_2.9.0-1-2.4-M1.jar:2.4-M1]
    at net.liftweb.actor.LAScheduler$$anonfun$9$$anon$2$$anon$3.run(LiftActor.scala:64) [lift-actor_2.9.0-1-2.4-M1.jar:2.4-M1]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_24]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_24]
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_24]
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/alternative; 
    boundary="----=_Part_8_877795714.1310372068000"
    at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:877) ~[na:1.6.0_24]
    at javax.activation.DataHandler.writeTo(DataHandler.java:302) ~[na:1.6.0_24]
    at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403) ~[mail-1.4.1.jar:1.4.1]
    at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1745) ~[mail-1.4.1.jar:1.4.1]
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1099) ~[mail-1.4.4.jar:1.4.4]
    ... 23 common frames omitted

After some time it can start working again.

I've tried solutions, recommended here and here. I've also tried excluding javax.activation, using both javax.mail 1.4.1 and 1.4.4. Neither solution worked. What could be the cause? Any help appreciated.


I was able to fix it by making mail.jar and activation.jar provided in my pom.xml.

      <dependency>
         <groupId>javax.mail</groupId>
         <artifactId>mail</artifactId>
         <version>1.4.1</version>
         <scope>provided</scope>
       </dependency>

The reason, I suppose, was that container already had mail.jar, and jdk 1.6 includes activation.jar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜