Hello Linkoln, Christian, I was trying to use Rewrite in my JSF app, but for some reason Rewrite is not reading my /META-INF/services/org.ocpsoft.rewrite.config.ConfigurationProvider file, my project structure is:
I put the same code inside of JSFCore to test, but this worked when I modified the file path “META-INF/services” to “../../META-INF/services” in ‘ServiceLoader’, can you explain me this?
I know the location of META-INF for webapps is a bit confusing. You are right that there is usually also a META-INF directory in the root of the webapp archive, but that’s a location where containers expect custom configuration files or other stuff. The META-INF folder in WEB-INF/classes instead is accessible from the classpath just like the corresponding files in JAR files. And ServiceLoader mechanism Rewrite uses requires the files to be on the classpath.
BTW: If you are using CDI for you webapp, you won’t have to add the services file at all for Rewrite to find your ConfigurationProvider. Just include the CDI integration module of Rewrite and Rewrite will automatically find ConfigurationProvider implementations which are managed by the CDI container.
Can you correct the documentation on this? I’ve fallen into the same trap because http://ocpsoft.org/rewrite/ mention the path is /META-INF/services/org.ocpsoft.rewrite.config.ConfigurationProvider instead of /WEB-INF/classes/META-INF/services/org.ocpsoft.rewrite.config.ConfigurationProvider.
Mentioning that you don’t need explicit ConfigurationProvider registration when you have CDI would also be a great help.