OmniFaces CDI

CDI

So, you got the following error in server log when using OmniFaces 2.x?

org.omnifaces.ApplicationInitializer checkCDIAvailable
SEVERE: 
████████████████████████████████████████████████████████████████████████████████
▌                         ▐█     ▐                                             ▐
▌    ▄                  ▄█▓█▌    ▐ OmniFaces failed to initialize!             ▐
▌   ▐██▄               ▄▓░░▓▓    ▐                                             ▐
▌   ▐█░██▓            ▓▓░░░▓▌    ▐ This OmniFaces version requires CDI, but    ▐
▌   ▐█▌░▓██          █▓░░░░▓     ▐ none was found on this environment.         ▐
▌    ▓█▌░░▓█▄███████▄███▓░▓█     ▐                                             ▐
▌    ▓██▌░▓██░░░░░░░░░░▓█░▓▌     ▐ OmniFaces 2.x requires a minimum of JSF 2.2.▐
▌     ▓█████░░░░░░░░░░░░▓██      ▐ Since this JSF version, the JSF managed bean▐
▌     ▓██▓░░░░░░░░░░░░░░░▓█      ▐ facility @ManagedBean is semi-official      ▐
▌     ▐█▓░░░░░░█▓░░▓█░░░░▓█▌     ▐ deprecated in favour of CDI. JSF 2.2 users  ▐
▌     ▓█▌░▓█▓▓██▓░█▓▓▓▓▓░▓█▌     ▐ are strongly encouraged to move to CDI.     ▐
▌     ▓▓░▓██████▓░▓███▓▓▌░█▓     ▐                                             ▐
▌    ▐▓▓░█▄▐▓▌█▓░░▓█▐▓▌▄▓░██     ▐ OmniFaces goes a step further by making CDI ▐
▌    ▓█▓░▓█▄▄▄█▓░░▓█▄▄▄█▓░██▌    ▐ a REQUIRED dependency next to JSF 2.2. This ▐
▌    ▓█▌░▓█████▓░░░▓███▓▀░▓█▓    ▐ not only ensures that your web application  ▐
▌   ▐▓█░░░▀▓██▀░░░░░ ▀▓▀░░▓█▓    ▐ represents the state of art, but this also  ▐
▌   ▓██░░░░░░░░▀▄▄▄▄▀░░░░░░▓▓    ▐ makes for us easier to develop OmniFaces,   ▐
▌   ▓█▌░░░░░░░░░░▐▌░░░░░░░░▓▓▌   ▐ without the need for all sorts of hacks in  ▐
▌   ▓█░░░░░░░░░▄▀▀▀▀▄░░░░░░░█▓   ▐ in order to get OmniFaces to deploy on      ▐
▌  ▐█▌░░░░░░░░▀░░░░░░▀░░░░░░█▓▌  ▐ environments without CDI.                   ▐
▌  ▓█░░░░░░░░░░░░░░░░░░░░░░░██▓  ▐                                             ▐
▌  ▓█░░░░░░░░░░░░░░░░░░░░░░░▓█▓  ▐ You have 3 options:                         ▐
██████████████████████████████████ 1. Downgrade to OmniFaces 1.x.              ▐
█░▀░░░░▀█▀░░░░░░▀█░░░░░░▀█▀░░░░░▀█ 2. Install CDI in this environment.         ▐
█░░▐█▌░░█░░░██░░░█░░██░░░█░░░██░░█ 3. Switch to a CDI capable environment.     ▐
█░░▐█▌░░█░░░██░░░█░░██░░░█░░░██░░█                                             ▐
█░░▐█▌░░█░░░██░░░█░░░░░░▄█░░▄▄▄▄▄█ For additional instructions, check          ▐
█░░▐█▌░░█░░░██░░░█░░░░████░░░░░░░█ http://omnifaces.org/cdi                    ▐
█░░░█░░░█▄░░░░░░▄█░░░░████▄░░░░░▄█                                             ▐
████████████████████████████████████████████████████████████████████████████████

Okay, here are the additional instructions:

  1. Downgrade to OmniFaces 1.x.
    This version doesn't require CDI. So you should be able to run it on CDI-less environments. You can find download links in the homepage.
  2. Install CDI 1.1+ in this environment.
    For Tomcat users who don't have freedom in server choice, refer this article: How to install CDI in Tomcat?
    When installing Weld, make sure that you're using a minimum of version 2.2.0! Older versions have initialization ordering bugs.
  3. Switch to a CDI 1.1 capable environment.
    For Tomcat users who have full freedom in server choice, just replace Tomcat by TomEE, or perhaps even by WildFly.

Got it

Go back to OmniFaces homepage then :)