JavaServer Faces.org

FAQ

  1. Q: I'm running Mojarra with mvn jetty:run, and my @ManagedBean, @Validator, and @Converter classes are missing, not found.  I can get it to work with mvn jetty:run-war, but this is very slow and cumbersome and kills the productivity of embedded Jetty. How can I get it working?

    A: The problem is that Mojarra (JSF 2 RI) scans three places for classes annotated with @ManagedBean:

    1. WEB-INF/classes
    2. JARS in WEB-INF/lib
    3. classpath with META-INF/faces-config.xml

    Since Jetty reads the class files from target/classes in embedded mode, JSF 2 doesn't know to scan them there (unless META-INF/faces-config.xml is present). Basically, instead of just scanning all classpath entries, Mojarra is very specific.

    If you really want to get productive with JSF 2 right out of the box w/ embedded Jetty, I recommend looking into the weld-jsf-servlet-minimal artifact, which prepares a JSF 2.0 and CDI 1.0 application for you.

    http://tinyurl.com/weld-archetypes

    If you use @Named classes (from CDI) rather than @ManagedBean (from JSF 2), a substitue I recommend anyway, then you can get the productive you want.

    Here is the workaround with Mojarra with regard to the scanning: https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1111. If you put faces-config.xml in src/main/resources/META-INF, then it will find the classes you want.