Search code examples
jsfmavenjettymanaged-bean

How to work-a-round with JSF annotation processing bug on Jetty?


There's a bug in JSF loading mechanism for managed beans annotated with annotation @ManagedBean. The mechanism is not activated when running the app via mvn jetty:run. The bug is reported here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=288243

This is a very nasty thing, because jetty:run have great advantages when debugging:

  • it is fast
  • it works directly with the jsf files from workspace, without need to use FileSync plugin

However, not supporting the annotation would require downgrading to XML configuration.

Is there any work-a-round for this bug?


Solution

  • source : the link you provided in your question , read Tomaz Lipinsi comments

    Hi, I've found a easy workaround for this problem. Actually I don't use Jetty but Tomcat and Sysdeo Tomcat Launcher but it behaves the same. JSF2 is looking for annotated classes in two places: - WEB-INF/classes - so if the app is not packaged into .war, this directory does not exist - classpath jars (WEB-INF/lib) - similar as above I've tried to override default com.sun.faces.spi.AnnotationProvider to my own so I could provide him a list of my classes (see JavaDoc for this class). While I was trying to do this then I hit upon an idea that I could just simply put my compilled classes in WEB-INF/classes dir. Adding this to pom.xml solved the problem:
    src/main/webapp/WEB-INF/classes The drawback is that now I have compiled classes in source dir but the most important is that it works.

    Suggest you to read all the comments there.