skip to Main Content

I’m using docker desktop on windows 11 to manage containers for my java web application. I build container images on my local and can run them without issue. When I push them to AWS and run them as a FARGATE service I get the following error when my application tries to send an email:

Exception in thread "Thread-2" java.lang.NoClassDefFoundError: jakarta/activation/DataContentHandler
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2287)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:797)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1272)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1120)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)…

I’m assuming that my containers should run the same no matter what environment they run in.

Can somebody please explain to me why I am wrong in my assumption?

I really don’t know what to try and change about my container because it works on my local.

2

Answers


  1. Chosen as BEST ANSWER

    I suspected that this was a java dependency tree issue and bounced the idea off of some my coworkers. Further analysis identified that our old ant build was packaging multiple versions of the same jar in the application deployment .war file causing a classic library collision issue.

    So we decided to drop the old ant build process and use Maven. After building out a Maven pom file to support our legacy application we were able to build and deploy a new image to AWS and the issue went away. I have seen class path issues like this in the past when running the same java application in windows and linux before, but expected a containerized deployment to mitigate the possibility of this occurring. Boy was I wrong.


  2. Your assumption is correct. If the class is found inside a locally running container the image must have it, also when running remotely. Hence doublecheck whether you really are running the same image.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search