Details
Description
During initialization, MyFaces assumes that the Web Application has been exploded in some location in the filesystem. This assumption is caused by heavily using ServletContext.getRealPath during initialization, as well as File objects to access xhtml pages.
This makes MyFaces behave badly in containers which do not need to explode WARs, e.g. Apache Karaf with PAX Web. It also hinders OSGi-friendliness.
I have pinpointed the following locations, at least:
- org.apache.myfaces.config.FacesConfigValidator (line 102 in v2.1.3): when validating the from-id and to-id in the navigation rules.
- org.apache.myfaces.webapp.AbstractFacesInitializer (line 320 in v2.1.3): when setting the context path for validations
- org.apache.myfaces.webapp.AbstractFacesInitializer (line 133 in v2.1.3): logging
It would be a good idea to refactor this code to use ServletContext.getResource, as naturally XHTML files are bound to be WAR resources anyway. This will also make MyFaces more implementation-agnostic.