Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven tomcat:run goal and jsf annotation based component/converter/validator scanning

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

like image 721
eglobetrotter Avatar asked Dec 10 '10 13:12

eglobetrotter


1 Answers

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.

like image 139
Andy Jackson Avatar answered Nov 15 '22 05:11

Andy Jackson