2

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.

Community
  • 1
  • 1
Hirofumi Okino
  • 975
  • 1
  • 10
  • 22

1 Answers1

3

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).
Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks. To be clear, are you suggesting to use the default MyFaces (instead of org.glassfish#javax.faces) while I'm using TomEE? If so, I will quickly adjust the html layout to MyFaces, and then, I try the first milestone of TomEE7! – Hirofumi Okino Dec 26 '15 at 10:00
  • 1
    Both are good. If you really want to use Mojarra, you should be upgrading in server end (just replace MyFaces jars in its `/lib` folder by Mojarra jar(s)), not in webapp end, so the pom remains unchanged. – BalusC Dec 26 '15 at 10:03
  • The /lib thing helps me too, I didn't even know that was nessesary, thanks again! – Hirofumi Okino Dec 26 '15 at 10:06
  • Usually only when the server already provides it out the box. You're welcome. – BalusC Dec 26 '15 at 10:12
  • I had difficulty fixing the layout and it was related to omniFaces, so I made another question: http://stackoverflow.com/questions/34471378/how-to-pass-css-styles-with-myfaces-omnifaces – Hirofumi Okino Dec 26 '15 at 12:36