Search code examples
mavenjsfjsf-2.2apache-tomeemojarra

What are the recommended JSF dependencies with TomEE1.7.x?


I've been developing a JSF2.0 (I'm not really sure about the JSF version) application on TomEE 1.7.3 (JavaEE6 based).

In my Maven pom.xml, I had too many dependencies which I've copied from many examples, but I reduced them to minimum requirements. Bellow is the "dependencies" part of my pom.xml:

<dependencies>
    <!-- JavaEE6 -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
    </dependency>
    <!-- /JavaEE6 -->

    <!-- OmniFaces for JSF, @Eager, postback same request parameters, etc. -->
    <dependency>
        <groupId>org.omnifaces</groupId>
        <artifactId>omnifaces</artifactId>
        <version>1.8.3</version>
    </dependency>
    <!-- /OmniFaces -->

    <!-- glassfish faces (is it called mojarra??) -->
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.faces</artifactId>
        <version>2.2.12</version>
        <scope>runtime</scope>
    </dependency>
    <!-- /glassfish faces -->

    <!-- some mysql connector -->
    <!-- some aws sdks, s3, ec2, etc -->
    <!-- some apache commons, StringUtils. etc -->
    <!-- some apache velocity -->
</dependencies>

The org.glassfish#javax.faces#2.2.12 dependency can be removed as well, but it causes html layout problem (with the bootstrap css). Downgrading it to version 2.0.x, causes the same layout problem. I know I can fix it, but it takes couple of hours.

What I want to ask is:

  1. Is it good or bad idea to use glassfish faces 2.2.x within TomEE1.7.x? TomEE's description says that it only supports up to JSF 2.0, but so far, it is working almost fine (I have few problems but those do not seem relevant to this version).
  2. Is it better to remove glassfish faces dependency and use the default MyFaces instead?
  3. Is it even better if I choose glassfish server, instead of TomEE, in my case?

BTW, I asked another question yesterday: JSF2.0 Some facesmessages not sent to redirected page on error handling

and I recognized that I have to clean up my project first, so it might help reduce my problems.

Thank you.


Solution

  • As you already said yourself, TomEE is a Java EE 6 container (and not a barebones JSP/Servlet container like Tomcat). So it has already (nearly) everything from Java EE 6 provided out the box, including JSF 2.0/2.1. Nearly, because it's actually a Java EE web profile container. So you should actually use javaee-web-api artifact ID.

    Only this should be sufficient:

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    

    As an Apache product, its bundled JSF implementation is actually MyFaces, not Mojarra.

    In case you intend to use JSF 2.2, which is part of Java EE 7, you should be using TomEE 7 instead and change the version in pom.

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    

    A milestone was released just this month, see the downloads page. Alternatives to TomEE 7 are WildFly 8+ or Payara 4+.

    See also:

    • Our JSF wiki page - also contains JSF installation instructions and Maven coordinates (and many more useful information to get started).