Details
Description
Using the cargo-maven2-plugin and jetty 6, you will get an application path like this: /private/var/folders/w4/w4XHIDXbF9OIP9d9vn2QjE+++TI/Tmp/Jetty_0_0_0_0_8080_myfaces-extcdi-cargo-test-0.9.1-SNAPSHOT.war_myfaces-extcdi-cargo-test_-lvwnpd/webapp/
Unfortunately this path contains some regex control characters like '+' and thus DefaultFaceletFactory fails with the following Exception when calling String.replaceFirst():
javax.faces.FacesException: java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 48
/private/var/folders/w4/w4XHIDXbF9OIP9d9vn2QjE+++TI/Tmp/Jetty_0_0_0_0_8080_myfaces-extcdi-cargo-test-0.9.1-SNAPSHOT.war_myfaces-extcdi-cargo-test_-lvwnpd/webapp/
^
at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241)
at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:191)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.execute(CodiLifecycleWrapper.java:55)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:285)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:751)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:500)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
Caused by: java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 48
/private/var/folders/w4/w4XHIDXbF9OIP9d9vn2QjE+++TI/Tmp/Jetty_0_0_0_0_8080_myfaces-extcdi-cargo-test-0.9.1-SNAPSHOT.war_myfaces-extcdi-cargo-test_-lvwnpd/webapp/
^
at java.util.regex.Pattern.error(Pattern.java:1713)
at java.util.regex.Pattern.sequence(Pattern.java:1878)
at java.util.regex.Pattern.expr(Pattern.java:1752)
at java.util.regex.Pattern.compile(Pattern.java:1460)
at java.util.regex.Pattern.<init>(Pattern.java:1133)
at java.util.regex.Pattern.compile(Pattern.java:823)
at java.lang.String.replaceFirst(String.java:2146)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory._createViewMetadataFacelet(DefaultFaceletFactory.java:308)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getViewMetadataFacelet(DefaultFaceletFactory.java:394)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getViewMetadataFacelet(DefaultFaceletFactory.java:376)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage._getViewMetadataFacelet(FaceletViewDeclarationLanguage.java:1902)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.access$000(FaceletViewDeclarationLanguage.java:128)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage$FaceletViewMetadata.createMetadataView(FaceletViewDeclarationLanguage.java:2136)
at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:161)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
... 20 more
String.replaceFirst() is used three times, in _createFacelet(), _createViewMetadataFacelet() and _createCompositeComponentMetadataFacelet(). Each time it is used to remove the path of the facelet-file.
The solution is to treat the search parameter as literal text and not as a regex. Thus doing exactly what String.replaceFirst() internally does, however, with Pattern.LITERAL set.