I'm developing a JSF 2.0 application (Mojarra+Primefaces) and using the maven build environment. Before I have used the faces-config.xml file for registering of my custom converters and validators, everything went well so far. Then I saw some syntactic sugar of JSF 2.0 - the annotation based configuration approach. And now I would like to use it, instead of the xml config file. A problem was that Mojarra didn't scan my annotated classes. I figured out that I needed to put the <faces-config ... metadata-complete="false">
attribute to false. Now it works but only if I start my application with mvn tomcat:run-war
goal and not with the mvn tomcat:run
dynamic project, which is more comfortable for development. The specification of JSP 2.0 says that:
If the element in the WEB-INF/faces-config.xml file contains metadata-complete attribute whose value is "true", the implementation must not perform annotation scanning on any classes except for those classes provided by the implementation itself. Otherwise, continue as follows.
If the runtime discovers a conflict between an entry in the Application Configuration Resources and an annotation, the entry in the Application Configuration Resources takes precedence. All classes in WEB-INF/classes must be scanned.
For every jar in the application's WEB-INF/lib directory, if the jar contains a "META-INF/faces-config.xml" file or a file that matches the regular expression ".*.faces-config.xml" (even an empty one), all classes in that jar must be scanned.
But it says nothing about dynamic projects running in maven build environment :)! Do anyone has a solution for that problem?
Cheers,
Kevin
I also had this problem, but found that adding the war:inplace goal made it work for me. i.e. use
mvn clean war:inplace tomcat:run
instead of just 'tomcat:run' and it should work just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With