error: module not found: jakarta.activation

Disclaimer: I am no Java expert and this article is mainly for my own reference as I solved this issue multiple times and forgot hot I resoved it every single time....

 

Here we are trying to resolve the message:

error: module not found: jakarta.activation

when building a maven project (in my case glassfish-jaxb).

There are a couple of indications and solutions that can fix it for example replacing the artifact names:

https://github.com/eclipse-ee4j/jaxb-stax-ex/issues/22#issuecomment-469287063

 

Steps to resolution should be:

  1. Run `mvn dependency:tree` to get an overview on dependencies and who might need "activation"
  2. Run mvn with debug logging to identify locations in the logs. Keep an eye out for "exclusion", "conflict", "module"
  3. Find the module that causes the error.
  4. Identify what other artifacts the failed module uses.
With that information, you can try fixing your source as mentioned in the link above. If you know your source is meant to build, check your OS. The OS might have some artifacts installed, that are required by your module (see step 4 above). These artifacts might be too new/different and require jakarta.activation. So that needs to be resolved.
In my case the istack-commons version was too new.
 
Some more background:
With Java 9, javax.activation has been deprecated and removed with Java 11. Eclipse has taken over the development. There are multiple solutions that offer these features like
glassfish-activation
JavaBeans Activation Framework (jaf)
jakarta-activation

Based on the used versions, the artifact name changes between com.sun.actication:javax.activation or jakarta.activation:jakarta.activation  or java.activation.

https://stackoverflow.com/questions/46493613/what-is-the-replacement-for-javax-activation-package-in-java-9

https://wiki.eclipse.org/Jakarta_EE_Maven_Coordinates