Couldn't send mail - java.lang.ClassCastException

4,931 views
Skip to first unread message

Hannes

unread,
Jun 20, 2011, 4:14:10 AM6/20/11
to lif...@googlegroups.com
Hi There,

I'm using Lift-2.3. Since I upgraded from Jetty 5 to Jetty 6, I cannot
send mails anymore:


ERROR - Couldn't send mail
java.lang.ClassCastException: gnu.mail.handler.TextPlain cannot be cast
to javax.activation.DataContentHandler
at
javax.activation.MailcapCommandMap.getDataContentHandler(MailcapCommandMap.java:596)
at
javax.activation.MailcapCommandMap.createDataContentHandler(MailcapCommandMap.java:550)
at
javax.activation.DataHandler.getDataContentHandler(DataHandler.java:611)
at javax.activation.DataHandler.writeTo(DataHandler.java:315)
at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:261)
at
javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1321)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2074)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2042)
at javax.mail.Transport.send(Transport.java:117)
at
net.liftweb.util.MailerImpl$$anon$4$$anonfun$$init$$4.apply(Mailer.scala:191)
at
net.liftweb.util.MailerImpl$$anon$4$$anonfun$$init$$4.apply(Mailer.scala:191)
at
net.liftweb.util.MailerImpl$class.performTransportSend(Mailer.scala:170)
at net.liftweb.util.Mailer$.performTransportSend(Mailer.scala:31)
at net.liftweb.util.MailerImpl$class.msgSendImpl(Mailer.scala:267)
at net.liftweb.util.Mailer$.msgSendImpl(Mailer.scala:31)
at
net.liftweb.util.MailerImpl$MsgSender$$anonfun$messageHandler$1.apply(Mailer.scala:154)
at
net.liftweb.util.MailerImpl$MsgSender$$anonfun$messageHandler$1.apply(Mailer.scala:151)
at
net.liftweb.actor.SpecializedLiftActor$class.execTranslate(LiftActor.scala:321)
at
net.liftweb.util.MailerImpl$MsgSender.execTranslate(Mailer.scala:150)
at
net.liftweb.actor.SpecializedLiftActor$class.net$liftweb$actor$SpecializedLiftActor$$proc2(LiftActor.scala:289)
at
net.liftweb.actor.SpecializedLiftActor$$anonfun$net$liftweb$actor$SpecializedLiftActor$$processMailbox$1.apply(LiftActor.scala:210)
at
net.liftweb.actor.SpecializedLiftActor$$anonfun$net$liftweb$actor$SpecializedLiftActor$$processMailbox$1.apply(LiftActor.scala:210)
at
net.liftweb.actor.SpecializedLiftActor$class.around(LiftActor.scala:224)
at net.liftweb.util.MailerImpl$MsgSender.around(Mailer.scala:150)
at
net.liftweb.actor.SpecializedLiftActor$class.net$liftweb$actor$SpecializedLiftActor$$processMailbox(LiftActor.scala:209)
at
net.liftweb.actor.SpecializedLiftActor$$anonfun$2$$anonfun$apply$mcV$sp$1.apply$mcV$sp(LiftActor.scala:173)
at
net.liftweb.actor.LAScheduler$$anonfun$9$$anon$2$$anon$3.run(LiftActor.scala:64)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)


The only thing I could find out is described in the following thread:
http://stackoverflow.com/questions/6101599/lift-mailer-error-gnu-mail-handler-textplain-cannot-be-cast-to-javax-activation

It says the problem only occurs with Jetty version < 6.1.25.

I really hope there's another solution besides upgrading to Jetty 7!


thanks.

Richard Dallaway

unread,
Jun 20, 2011, 5:27:18 AM6/20/11
to lif...@googlegroups.com
If you don't want to go to 7, there are versions of 6 beyond 6.1.24 or 25.  I don't see the problem on Jetty 6.1.26 on MacOS or Ubuntu if that's of any help.

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.


Hannes

unread,
Jun 20, 2011, 5:38:52 AM6/20/11
to lif...@googlegroups.com
Hi Richard,

Apparently I'm using Ubuntu Server 10.04 and therefore the supported Jetty version is 6.1.22...

I want to stick with the stable repository, so this means I've to build Jetty?


thanks.

Richard Dallaway

unread,
Jun 20, 2011, 5:54:37 AM6/20/11
to lif...@googlegroups.com
I can't say for sure in your case exactly what the issue is, but there's a couple of pieces of evidence suggesting trying a new Jetty would get you past this problem quickly (for some values of quickly....).

I totally understand why you want to go with the stable distribution versions of packages. We didn't because we like the flexibility of flipping between or upgrading containers to suit our needs.  It's not so bad.  Essentially, it's a download and unzip. There's no "build" as such.  But you need to weigh that against having to mess with, or roll your own, /etc/rc.d start up scripts and general management headaches.

If you can reproduce your problem, it's not too hard to grab and unzip a different Jetty and see if it solves the issue for you in a way you like.  

Richard

Jeppe Nejsum Madsen

unread,
Jun 20, 2011, 6:30:01 AM6/20/11
to lif...@googlegroups.com
Hi,

I can't recall if we had the exact same issue, but we did have some
class-cast issues sending mail. It was solved by installing both

libgnujaf-java and libgnumail-java

/Jeppe

Hannes

unread,
Jun 20, 2011, 9:34:55 AM6/20/11
to lif...@googlegroups.com
Hi Jeppe,

The packages you mentioned before were already installed.

I just downloaded and started Jetty 7 and now it seems to work....

Still, I would prefer another solution. Is this error a bug of Jetty <
6.1.25 ?


thanks.

Tim Nelson

unread,
Jun 20, 2011, 9:47:55 AM6/20/11
to lif...@googlegroups.com
Hi,

I've been using Ubuntu Server 10.04 and Jetty 6.1.22 since they've been released and have never had problems sending email.

What version of the activation jar is on your classpath? Mine's 1.1

Tim

Hannes

unread,
Jun 20, 2011, 11:11:06 AM6/20/11
to lif...@googlegroups.com
Hi Tim,

I did a 'locate activation' on my system and I found out that

- for Jetty 7.4.2, activation 1.1.0 is part of the ZIP file
- where on Jetty 6.1.22 (from APT) it looks like its 1.1.1

/usr/share/java/activation-1.1.1.jar
/usr/share/java/activation.jar
/usr/share/jetty/lib/naming/activation.jar

Further on, the CLASS_PATH variable is not set on my system. Do I've to set it in /etc/jetty/jetty.conf (for 6.1.22) ?


thanks you!

To view this discussion on the web visit https://groups.google.com/d/msg/liftweb/-/jwO33otKX5AJ.

Tim Nelson

unread,
Jun 20, 2011, 11:45:29 AM6/20/11
to lif...@googlegroups.com
Hi,

I don't have any of the jar files you listed on my server. My activation jar is in the WEB-INF/lib folder of my webapp. I believe Lift brings in activation-1.1.jar for me. It looks like you installed package libjetty-extra [1] which installs the activation jars for you. I did not install this, so that's the difference in our configs.

There could be a conflict there. Do you also have the activation-1.1.jar in your WEB-INF/lib folder?

Tim


>> For more options, visit this group at
>> http://groups.google.com/group/liftweb?hl=en.
>>
>>

Hannes

unread,
Jun 20, 2011, 5:23:38 PM6/20/11
to lif...@googlegroups.com
On 20.06.2011 17:45, Tim Nelson wrote:
Hi,

I don't have any of the jar files you listed on my server. My activation jar is in the WEB-INF/lib folder of my webapp. I believe Lift brings in activation-1.1.jar for me. It looks like you installed package libjetty-extra [1] which installs the activation jars for you.
That's right, I had installed the libjetty-extra package. I removed it, restarted Jetty, but I didn't help...

I did not install this, so that's the difference in our configs.

There could be a conflict there. Do you also have the activation-1.1.jar in your WEB-INF/lib folder?

No, its only the folders I listed before.

So, at least for now, it seems I've to stay with Jetty 7 which doesn't produce the error. Do you think there are any other possibilities?


thanks.
To view this discussion on the web visit https://groups.google.com/d/msg/liftweb/-/X8_VbXHfGwQJ.

Tim Nelson

unread,
Jun 20, 2011, 5:51:20 PM6/20/11
to lif...@googlegroups.com
Hi,

If you removed the libjetty-extra package, that should have deleted the activation jars in /usr/share. Are those gone?

Also, Lift-Util has a dependency on JavaMail which has a dependency on Activation, so you should have WEB-INF/lib/activation-1.1.jar file. So it seems odd that you say it's not there.


>> For more options, visit this group at
>> http://groups.google.com/group/liftweb?hl=en.
>>
>>

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To view this discussion on the web visit https://groups.google.com/d/msg/liftweb/-/jwO33otKX5AJ.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftwe...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
--
You received this message because you are subscribed to the Google Groups "Lift" group.

Naftoli Gugenheim

unread,
Jun 20, 2011, 6:26:07 PM6/20/11
to lif...@googlegroups.com
No, you can download the .deb and install it with dpkg.

Volker

unread,
Jul 28, 2011, 6:23:59 AM7/28/11
to Lift
Hi Hannes!

The problem also occured on my ubuntu 10.4 server. I did the following
to solve the problem:

First I copied the activation.jar and mail.jar from a maven repository
to /usr/share/java:
cd /usr/share/java
sudo cp ~/.m2/repository/javax/activation/activation/1.1/
activation-1.1.jar .
sudo cp ~/.m2/repository/javax/mail/mail/1.4.1/mail-1.4.1.jar .
sudo rm activation.jar
sudo ln -s activation-1.1.jar activation.jar
sudo ln -s mail-1.4.1.jar mail.jar

Then I edited '/etc/jetty/start.config' and replaced gnumail.jar with
mail.jar

I also changed the JDK_DIR of jetty to java-6-sun, but i don't know,
whether this is necessary to solve the problem.

After a restart of jetty the mailing worked again as on my local
development host.

Andrew Mullins

unread,
Aug 15, 2011, 10:23:31 PM8/15/11
to lif...@googlegroups.com
Any ideas on how to fix this issue while using sbt?
I'm currently deleting the activation-1.1.jar from the server after I've unpacked my war file, but I'd like to exclude it via my sbt (0.7.7) project file.

Andrew Mullins

unread,
Aug 15, 2011, 10:45:38 PM8/15/11
to lif...@googlegroups.com
I guess I should have search google, first...

override def ivyXML = <dependencies>
  <dependency org="javax.mail" name="mail" rev="1.4.1">
    <exclude module="activation" />
  </dependency>
</dependencies>
Reply all
Reply to author
Forward
0 new messages