TomEE 9 targets javax->jakarta package switch. However, you can get some surprises when getting started with it.

The first one will likely be you don't find it. Since this distribution is not yet "native" - I'll explain after what it means, it is not in org.apache.tomee groupId but org.apache.tomee.jakarta. It is also important to note that it is the only jakarta artifact, no openejb jakarta, no tomee maven plugin jakarta etc...

Then, here is what you will find in tomee/lib folder:

...
lib/bval-jsr-2.0.5.jar
...
lib/geronimo-config-impl-1.2.1.jar
lib/geronimo-health-1.0.1.jar
lib/geronimo-health-common-1.0.1.jar
lib/geronimo-javamail_1.6_mail-1.0.0.jar
lib/geronimo-metrics-1.0.2.jar
lib/geronimo-metrics-common-1.0.2.jar
lib/geronimo-openapi-impl-1.0.12.jar
lib/geronimo-opentracing-1.0.0.jar
lib/geronimo-transaction-3.1.4.jar
...
lib/jakarta.activation-1.2.1.jar
lib/jakarta.xml.bind-api-2.3.2.jar
...
lib/johnzon-core-1.2.5.jar
lib/johnzon-jaxrs-1.2.5.jar
lib/johnzon-jsonb-1.2.5.jar
lib/johnzon-mapper-1.2.5.jar
...
lib/mbean-annotation-api-8.0.5.jar
lib/microprofile-config-api-1.3.jar
lib/microprofile-fault-tolerance-api-1.1.4.jar
lib/microprofile-health-api-1.0.jar
lib/microprofile-jwt-auth-api-1.1.1.jar
lib/microprofile-metrics-api-1.1.1.jar
lib/microprofile-openapi-api-1.1.2.jar
lib/microprofile-opentracing-api-1.1.2.jar
lib/microprofile-rest-client-api-1.3.3.jar
...
lib/mp-common-8.0.5.jar
lib/mp-jwt-8.0.5.jar
...
lib/myfaces-api-2.3.6.jar
lib/myfaces-impl-2.3.6.jar
...
lib/neethi-3.0.3.jar
lib/openejb-api-8.0.5.jar
lib/openejb-client-8.0.5.jar
lib/openejb-core-8.0.5.jar
lib/openejb-cxf-8.0.5.jar
lib/openejb-cxf-rs-8.0.5.jar
lib/openejb-cxf-transport-8.0.5.jar
lib/openejb-ejbd-8.0.5.jar
lib/openejb-hsql-8.0.5.jar
lib/openejb-http-8.0.5.jar
lib/openejb-javaagent.jar
lib/openejb-jee-8.0.5.jar
lib/openejb-jee-accessors-8.0.5.jar
lib/openejb-jpa-integration-8.0.5.jar
lib/openejb-loader-8.0.5.jar
lib/openejb-rest-8.0.5.jar
lib/openejb-server-8.0.5.jar
lib/openejb-webservices-8.0.5.jar
...
lib/openjpa-3.1.2.jar
...
lib/opentracing-api-0.31.0.jar
lib/openwebbeans-ee-2.0.12.jar
lib/openwebbeans-ee-common-2.0.12.jar
lib/openwebbeans-ejb-2.0.12.jar
lib/openwebbeans-el22-2.0.12.jar
lib/openwebbeans-impl-2.0.12.jar
lib/openwebbeans-jsf-2.0.12.jar
lib/openwebbeans-spi-2.0.12.jar
lib/openwebbeans-web-2.0.12.jar
...
lib/tomee-catalina-8.0.5.jar
lib/tomee-common-8.0.5.jar
lib/tomee-config-8.0.5.jar
lib/tomee-jaxrs-8.0.5.jar
lib/tomee-jdbc-8.0.5.jar
lib/tomee-loader-8.0.5.jar
lib/tomee-mojarra-8.0.5.jar
lib/tomee-myfaces-8.0.5.jar
lib/tomee-security-8.0.5.jar
lib/tomee-webapp-8.0.5.jar
lib/tomee-webservices-8.0.5.jar
  • I didn't make a typo, I listed a TomEE 9 lib folder and you see TomEE 8 jars.
  • OpenWebBeans, BVal, Johnzon have jakarta jars - using relocations - but they are not in TomEE 9 (jakarta) distribution.
  • MyFaces which has an official jakarta branch is in version 2 and not 3 which is the jakarta release.
  • TomEE 9 microprofile contains microprofile stack and other EE libraries which are not jakarta yet.

Another weird thing happens if you check Tomcat jars:

apache-tomee-microprofile-9.0.0-M3 $ unzip -p lib/tomcat-coyote.jar META-INF/MANIFEST.MF | grep Implementation-Version
Implementation-Version: 9.0.39

Yes, the built-in Tomcat version is the 9 and not tomcat 10 which targets Jakarta.

How can it work? Why these inconsistencies? Simply because TomEE 9 is for now a rebuild of TomEE 8 with jakarta relocations. You can see it as a big "replace" build hack - but don't get me wrong, it works fine.

The main issue with such a packaging is that you don't get the best of the libraries which are jakarta native and can have some specificities compared to javax flavor - for now it is almost nothing but it will come quickly for the native implementations.

So the solution is to replace the implementations until TomEE switches itself and while the integration code still works - it is the case as of today.

So our goal is to remove myfaces 2 and add myfaces 3, and to remove catalina/tomcat jars to add their version 10.

Indeed you can do it with a shell script or manually but I propose you to do it with TomEE Maven plugin.

Wait, TomEE 9 does not have a TomEE Maven Plugin so how to do? Well, let's use TomEE Maven Plugin 8. The plugin is actually a TomEE packager plugin so you can use it to package a TomEE, another TomEE version or even a Tomcat.

Here is how you can switch MyFaces and Tomcat version:

<plugin>
	<groupId>org.apache.tomee.maven</groupId>
	<artifactId>tomee-maven-plugin</artifactId>
	<version>8.0.5</version> <!-- 1 -->
	<executions>
		<execution>
			<id>prepare-distribution</id>
			<phase>none</phase>
			<goals>
				<goal>build</goal>
			</goals>
			<configuration> <!-- 2 -->
				<attach>false</attach>
				<zip>false</zip>
				<catalinaBase>${project.build.directory}/tomee/standalone</catalinaBase>
			</configuration>
		</execution>
	</executions>
	<configuration>
        <!-- 3 -->
		<context>ROOT</context>
		<warFile>${project.build.directory}/${project.build.finalName}</warFile>

        <!-- 4 -->
		<tomeeGroupId>org.apache.tomee.jakarta</tomeeGroupId>
		<tomeeVersion>9.0.0-M3</tomeeVersion>
		<tomeeClassifier>microprofile</tomeeClassifier>

		<!-- 5 -->
		<libs>
			<lib>remove:myfaces</lib>
			<lib>org.apache.myfaces.core:myfaces-api:3.0.0-RC1</lib>
			<lib>org.apache.myfaces.core:myfaces-impl:3.0.0-RC1</lib>
			<lib>remove:catalina</lib>
			<lib>remove:tomcat</lib>
			<lib>remove:servlet-api</lib>
			<lib>org.apache.tomcat:tomcat-catalina-ant:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-catalina-ha:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-catalina:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-ssi:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-storeconfig:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-tribes:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-api:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-coyote:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-dbcp:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-i18n-cs:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-i18n-es:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-i18n-fr:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-i18n-ja:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-i18n-ko:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-i18n-pt-BR:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-i18n-ru:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-i18n-zh-CN:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-jdbc:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-jni:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-util:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-util-scan:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-websocket:10.0.0</lib>
			<lib>org.apache.tomcat:tomcat-servlet-api:10.0.0</lib>
		</libs>
	</configuration>
</plugin>
  1. Don't forget to use TomEE 8 plugin since TomEE 9 plugin does not exist yet.
  2. We configure the build to not attach the distribution - since these days we often put the distribution in a docker or so it is useless to attach it to the build - but you can if desired.
  3. Assuming the pom you add this plugin in is a war module, we configure the war to be deployed as root application (http://localhost:8080/ to hit it) and we use the exploded war instead of .war archive to avoid to force tomcat to extract the archive at first startup (useless work).
  4. We configure the coordinates of the distribution we want to build from (TomEE 9 Microprofile here).
  5. We configure the library tuning we did. It uses a nice hack <lib> tag supports. remove:prefix enables to remove all the files from lib directory of the source distribution which matches the prefix. For example, remove:myfaces, will remove myfaces-impl-2.3.6.jar and myfaces-api-2.3.6.jar. Then, once the library is removed we just add them back using the coordinates of the jakarta native implementation. We do it for myfaces and tomcat.

Once done, you can run:

$ mvn clean package tomee:build@prepare-distribution
...
[INFO] --- tomee-maven-plugin:8.0.5:build (prepare-distribution) @ project ---
[INFO] TomEE was unzipped in '/project/target/tomee/standalone'
[INFO] Removed not mandatory default webapps
[INFO] Deleted /project/target/tomee/standalone/lib/myfaces-api-2.3.6.jar
[INFO] Deleted /project/target/tomee/standalone/lib/myfaces-impl-2.3.6.jar
[INFO] Copied 'org.apache.myfaces.core:myfaces-api:3.0.0-RC1' in '/project/target/tomee/standalone/lib/myfaces-api-3.0.0-RC1.jar
[INFO] Copied 'org.apache.myfaces.core:myfaces-impl:3.0.0-RC1' in '/project/target/tomee/standalone/lib/myfaces-impl-3.0.0-RC1.jar
[INFO] Deleted /project/target/tomee/standalone/lib/catalina-ha.jar
[INFO] Deleted /project/target/tomee/standalone/lib/catalina-ssi.jar
[INFO] Deleted /project/target/tomee/standalone/lib/catalina-ant.jar
[INFO] Deleted /project/target/tomee/standalone/lib/catalina-tribes.jar
[INFO] Deleted /project/target/tomee/standalone/lib/catalina.jar
[INFO] Deleted /project/target/tomee/standalone/lib/catalina-storeconfig.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-i18n-fr.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-api.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-jni.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-i18n-de.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-websocket.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-i18n-ko.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-i18n-ja.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-util-scan.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-i18n-cs.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-dbcp.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-util.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-coyote.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-jdbc.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-i18n-es.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-i18n-ru.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-i18n-pt-BR.jar
[INFO] Deleted /project/target/tomee/standalone/lib/tomcat-i18n-zh-CN.jar
[INFO] Copied 'org.apache.tomcat:tomcat-catalina-ant:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-catalina-ant-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-catalina-ha:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-catalina-ha-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-catalina:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-catalina-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-ssi:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-ssi-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-storeconfig:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-storeconfig-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-tribes:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-tribes-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-api:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-api-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-coyote:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-coyote-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-dbcp:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-dbcp-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-i18n-cs:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-i18n-cs-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-i18n-es:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-i18n-es-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-i18n-fr:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-i18n-fr-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-i18n-ja:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-i18n-ja-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-i18n-ko:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-i18n-ko-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-i18n-pt-BR:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-i18n-pt-BR-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-i18n-ru:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-i18n-ru-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-i18n-zh-CN:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-i18n-zh-CN-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-jdbc:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-jdbc-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-jni:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-jni-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-util:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-util-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-util-scan:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-util-scan-10.0.0.jar
[INFO] Copied 'org.apache.tomcat:tomcat-websocket:10.0.0' in '/project/target/tomee/standalone/lib/tomcat-websocket-10.0.0.jar

The plugin shows the actual manipulation it does on the libraries.

Side note: the fact we replaced servlet-api jar by the official tomcat one also solves a lot of warning you can get when deploying an application and enables to use Tomcat XML validation whereas TomEE 9.0.0-M3 lost that feature (a bug in the relocation process).

Now, if you go in /project/target/tomee/standalone, you have a TomEE instance with your application ready to run your jakarta code :).

 

From the same author:

In the same category: