jsfprimefacesjakarta-migration

Cannot compile/deploy PrimeFaces app to Jakarta EE server because it's looking for javax classes instead of jakarta classes


I'm migrating a JSF+PrimeFaces app from Java EE (javax.*) to Jakarta EE (jakarta.*). My target runtime happens to be Payara Micro 5.2022.4.

JSF part works fine but PrimeFaces part fails every time. It appears that it's trying to look for javax packaged classes instead of the intended jakarta packaged classes.

Examples of errors:

[ERROR] class file for javax.faces.event.FacesEvent not found

Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletRequestListener

Caused by: java.lang.ClassNotFoundException: javax.faces.context.FacesContextFactory

I've configured the PrimeFaces dependency as follows:

<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>11.0.0</version>
</dependency>

How is this caused and how can I solve it?


Solution

  • You need to explicitly specify the jakarta classifier to make sure it pulls the Jakarta EE variant instead of the Java EE variant.

    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>11.0.0</version>
        <classifier>jakarta</classifier>
    </dependency>
    

    This is only necessary for PrimeFaces versions 10.0.0 until 15.0.0. PrimeFaces 16.0.0 will be the first one exclusively for Jakarta EE, so you won't need the classifier anymore by then.