0

I want to use JSF 2.2 with Omnifaces 2.3.

I added omnifaces 2.3 jar in /WEB-INF/lib and I added POM.xml configuration:

<dependencies>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.faces</artifactId>
            <version>2.2.13</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4.1208</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.sun.el</groupId>
            <artifactId>el-ri</artifactId>
            <version>1.0</version>
        </dependency>
        <!-- We need this to send e-mails -->
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
            <version>1.5.5</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-core</artifactId>
            <version>1.2.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-web</artifactId>
            <version>1.2.4</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>omnifaces</artifactId>
            <version>2.3</version>
        </dependency>
    </dependencies>

But when I tried to use I get this error:

javax.faces.FacesException: Expression Error: Named Object: org.omnifaces.component.validator.ValidateEqual not found.
    at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1912)
    at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1166)
    at javax.faces.application.ApplicationWrapper.createComponent(ApplicationWrapper.java:637)
    at javax.faces.application.ApplicationWrapper.createComponent(ApplicationWrapper.java:637)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(ComponentTagHandlerDelegateImpl.java:602)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:175)

I suppose that omnifaces jar is not found. Can you propose some solution?

I updated project POM file this way:

<dependencies>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.faces</artifactId>
            <version>2.2.13</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4.1208</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>        
        <dependency>
            <groupId>com.sun.el</groupId>
            <artifactId>el-ri</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
        <!-- We need this to send e-mails -->
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
            <version>1.5.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-core</artifactId>
            <version>1.2.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-web</artifactId>
            <version>1.2.4</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>omnifaces</artifactId>
            <version>2.3</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
  • Similar problem here: http://stackoverflow.com/questions/32327848 Looks like to be related to an odd way of building and executing the web application. The concrete exception at least suggests that the OmniFaces JAR is not in /WEB-INF/lib folder of the deployed WAR, but is misplaced elsewhere in the runtime classpath (e.g. server's /lib, or some other shared path). – BalusC May 17 '16 at 05:03
  • Well, I placed javax.faces-2.2.13.jar and omnifaces-2.3.jar into Tomee lib folder and I managed to run it. – Peter Penzov May 17 '16 at 08:50
  • You're using TomEE instead of Tomcat? This server bundles way more libraries out the box than Tomcat. This server also uses MyFaces instead of Mojarra. You should remove all dependencies from pom which are **already** provided by server, or at least explicitly mark them as `provided`. This covers among others JSF, EL, CDI and JSTL. – BalusC May 17 '16 at 08:51
  • Just one idea: Is this the proper location: `main_folder_project\src\main\webapp\WEB-INF\lib\omnifaces-2.3.jar` – Peter Penzov May 17 '16 at 08:56
  • I updated the post. Which dependencies I can remove? – Peter Penzov May 17 '16 at 09:16
  • The server-provided ones. Then, install OmniFaces the normal way as per its instructions (it does **not** belong in server, it must be provided via webapp itself). – BalusC May 17 '16 at 09:21
  • I agree but it's not working and so far I can't find the root cause for this. Just to be sure is this the proper location: `main_folder_project\src\main\webapp\WEB-INF\lib\omnifaces-2.3.jar`? – Peter Penzov May 17 '16 at 09:24
  • It must be provided via webapp, so remove `provided` for OmniFaces, as that means "The server already provides it". And, when using Maven, you **do not** need to manually carry around loose JAR files. Otherwise you might still end up with duplicates. – BalusC May 17 '16 at 09:44
  • Ok thanks. Finaly I deleted Tomee cache and now it's running. Thanks! – Peter Penzov May 17 '16 at 09:56
  • Additional information: I removed `myfaces-api-2.1.17.jar` and `myfaces-impl-2.1.17.jar` from Tomee's lib directory. I placed `javax.faces-2.2.13.jar` into Tomee's lib directory and It's working fine. I would like if it's possible to always to use standart installation without replacing jar files. Can I somehow use `javax.faces-2.2.13.jar` from my war package? I know that it's not a good practice but is there any other better solution? – Peter Penzov May 17 '16 at 10:35

0 Answers0