Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaMail implementation provided by Jetty makes JavaMail unusable on Java 11 due to missing JAF #2960

Closed
izstas opened this issue Oct 5, 2018 · 6 comments
Assignees

Comments

@izstas
Copy link

izstas commented Oct 5, 2018

I am running Jetty 9.4.12.v20180830 on OpenJDK 11 (build 11+28), and I am unable to use JavaMail with java.lang.ClassNotFoundException: javax.activation.DataSource.

I have a webapp packaged as a .war which uses JavaMail, and this is the situation I find myself in:

  • The application has a JavaMail implementation on its classpath (in WEB-INF/lib).
  • The application has a JAF implementation on its classpath.
  • I have Jetty's mail module enabled as a transitive dependency of another module, and in accordance with System Classes classloading rules, JavaMail implementation provided by Jetty is loaded instead of the implementation on webapp's classpath.
  • I get the aforementioned exception because Java 11 doesn't include JAF, and even though I have its implementation on the classpath of my webapp, it is not used because the parent classloader that loads the JavaMail implementation provided by Jetty doesn't use that classpath.

There are several workarounds for this issue:

  • Remove the JavaMail implementation from ./lib/mail - that allows the implementation on webapp's classpath to be loaded using the webapp classloader
  • Add a JAF implementation to ./lib/mail - that makes it available to the parent classloader
  • Edit the list of System Classes to exclude javax.mail
@joakime
Copy link
Contributor

joakime commented Oct 5, 2018

Are you using the following dependency in your war?

<dependency>
    <groupId>com.sun.activation</groupId>
    <artifactId>javax.activation</artifactId>
    <version>1.2.0</version>
</dependency>

@joakime
Copy link
Contributor

joakime commented Oct 5, 2018

I guess that dependency could be in your ${jetty.base}/lib/ext/ directory as well (if you have the --module=ext enabled)

@janbartel janbartel self-assigned this Oct 8, 2018
@janbartel
Copy link
Contributor

@izstas have a look at issues #1600 and #1597.

The best thing for you to do is to create your own mail module following the instructions in #1600. That way you can place whatever version of javax jars and its transitive dependencies onto the container classpath, and it will be portable across jetty versions. Note that in jetty-10 we've removed the mail and transaction modules anyway, so your custom mail module will be needed anyway.

@janbartel
Copy link
Contributor

Closing this issue, please reopen if you feel we haven't addressed your concerns.

@vmassol
Copy link

vmassol commented Mar 3, 2020

Hello @janbartel (long time no talk ;)). Thanks for the explanations about this issue, which we're hitting on XWiki in our automated functional tests. We're using the official jetty image from dockerhub. Do you see a way to disable the mail module from the docker run command line (without having to create our own custom image)? Thanks a lot. I've checked https://www.eclipse.org/jetty/documentation/9.4.x/startup-modules.html but all I see is editing some init file or removing it which is more complex since it would require a custom Dockerfile and a new image.

Thanks a lot
-Vincent

@joakime
Copy link
Contributor

joakime commented Mar 3, 2020

@vmassol see appropriate/docker-jetty#108 - a fix to the official docker images should be done there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants