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

NoClassDefFoundError when parsing emails with jakarta classes #109

Open
sixcorners opened this issue Apr 11, 2024 · 1 comment
Open

NoClassDefFoundError when parsing emails with jakarta classes #109

sixcorners opened this issue Apr 11, 2024 · 1 comment
Assignees
Labels
duplicate This issue or pull request already exists

Comments

@sixcorners
Copy link

sixcorners commented Apr 11, 2024

If you bring in
implementation("com.google.appengine:appengine-api-1.0-sdk:2.0.25")
and
implementation("com.sun.mail:jakarta.mail:2.0.1")
it will break when you try to parse emails.

java.lang.NoClassDefFoundError: javax/activation/DataContentHandler
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:508)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:468)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:518)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:468)
	at jakarta.activation.MailcapCommandMap.getDataContentHandler(MailcapCommandMap.java:613)
	at jakarta.activation.MailcapCommandMap.createDataContentHandler(MailcapCommandMap.java:591)
	at jakarta.activation.CommandMap.createDataContentHandler(CommandMap.java:210)
	at jakarta.activation.DataHandler.getDataContentHandler(DataHandler.java:588)
	at jakarta.activation.DataHandler.getContent(DataHandler.java:515)
	at jakarta.mail.internet.MimeMessage.getContent(MimeMessage.java:1484)
...
Caused by: java.lang.ClassNotFoundException: javax.activation.DataContentHandler
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:518)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:468)
	... 21 more

I'm not sure how this should be fixed. I think the mailcap file is registering some handlers that jakarta mail is trying to load. I don't see a way to differentiate between classes that should be loaded by jakarta mail vs javax mail. I really hate the javax name change.

If you add
implementation("javax.activation:activation:1.1.1")
then it says

java.lang.ClassCastException: class org.apache.geronimo.mail.handlers.MultipartHandler cannot be cast to class jakarta.activation.DataContentHandler (org.apache.geronimo.mail.handlers.MultipartHandler and jakarta.activation.DataContentHandler are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @663c9e7a)
	at jakarta.activation.MailcapCommandMap.getDataContentHandler(MailcapCommandMap.java:620)
	at jakarta.activation.MailcapCommandMap.createDataContentHandler(MailcapCommandMap.java:591)
	at jakarta.activation.CommandMap.createDataContentHandler(CommandMap.java:210)
	at jakarta.activation.DataHandler.getDataContentHandler(DataHandler.java:588)
	at jakarta.activation.DataHandler.getContent(DataHandler.java:515)
	at jakarta.mail.internet.MimeMessage.getContent(MimeMessage.java:1484)
...
@ludoch ludoch self-assigned this Apr 29, 2024
@ludoch
Copy link
Collaborator

ludoch commented Apr 29, 2024

For historical compatibility issues, we still rely on ancient geronimo https://github.com/GoogleCloudPlatform/appengine-java-standard/blob/main/external/geronimo_javamail/pom.xml#L47

Might be time to revisit this dep for EE 10, looking at it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants