2

I'am developing a webapp using google app engine and maven in intelliJ IDEA.

So far so good until I tried to send an email using javax.mail and I get this error:

java.lang.NoClassDefFoundError: javax/activation/DataContentHandler

I have already put the dependencies needed (javax.activation & javax.mail) in the pom.xml and still this error occurs.

One way to fix it locally is to add "--add-modules java.activation" in vm options and when i run it locally its working fine and sending the email, but when I'am deploying the app its not working.

And my question is, is there any way to pass the vm argument to maven or anywhere else so it will run without the error when I'll deploy the app.

Or is there any other way to do this (with javax.mail or not) ?

My java version is: openjdk 10.0.2

Gayan Mettananda
  • 1,498
  • 14
  • 21
timos222
  • 48
  • 1
  • 9
  • Where you are deploying the application - Tomcat, Jboss or any other server? You have to specify `--add-modules java.activation` on the server startup script. – Ramesh Subramanian Jan 24 '19 at 07:40

2 Answers2

1

Just include the java.activation module in your application.

You can use either the older Oracle version, or the newer Eclipse version, which is essentially the same.

(And you should consider upgrading to JDK 11.)

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40
  • You know how can i do that in intelliJ? (If you mean the dependencies in maven, i already did this) – timos222 Jan 24 '19 at 12:55
  • If you're using Maven to create a war file for deployment, you should be able to tell it to package the dependencies in the war file along with your application. – Bill Shannon Jan 25 '19 at 04:18
  • in my case, in my intellij im have set on the project JDK 11 instead 8. – Brendon Iwata Sep 02 '20 at 20:33
  • I have the same issue and I'm using Visual Studio Code with JDK 11. I can see activation-1.1.1.jar getting included in my project's WEB-INF/lib when I include the maven plugin in my pom.xml, but I still get the error. Not sure what's wrong. – DFB Feb 16 '21 at 12:53
0

You could do that with docker containers. How to properly set the JVM options in a flexible GAE application

Cause with maven you can not set the VM options for run time. Trying via docker could be key.

ygbgames
  • 191
  • 9