[ 
https://issues.apache.org/jira/browse/MYFACES-4002?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14718492#comment-14718492
 ] 

Thomas Timbul commented on MYFACES-4002:
----------------------------------------

I assume you created each of those files for your test in the webxml 
subdirectory. Did it say what it couldn't find? Was the file:// prefix added?

I suppose one question is where exactly this {{file://}} scheme is added, 
because it's not part of the original web.xml. I'm full time on something else 
right now, so unfortunately lack time. Hopefully I'll get another chance at 
some point to look into this in more detail again and help figure out the root 
source of the issue.

> Regression? - References to external entities not working with WebXmlParser
> ---------------------------------------------------------------------------
>
>                 Key: MYFACES-4002
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4002
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.2.4
>         Environment: Myfaces 2.2.4, Tomcat 8.0.23, JDK 1.8_20, Windows 7 64bit
>            Reporter: Thomas Timbul
>         Attachments: patch1.txt
>
>
> I've searched JIRA and there are a few issues related to WebXmlParser, but 
> this seems almost like a recurrence of MYFACES-1754.
> My web.xml is split into multiple files, each declared as an XML entity 
> relative to the web.xml file itself:
> {code:xml}
> <!ENTITY contextparams        SYSTEM  "webxml/context-params.xml">
> {code}
> (As a side note I used to use 
> {{jndi:/localhost/WEB-INF/webxml/context-params.xml}}, but for some reason 
> Tomcat 8 claims that jndi is an invalid protocol).
> Using resource relative system identifiers Tomcat is now happy and the 
> context starts correctly. However, during its initialization MyFaces 
> re-parses the web.xml descriptor and resolves the entities incorrectly, 
> leading to failure with the message:
> {code}
> 2015-06-17 15:48:13.853 [localhost-startStop-1] ERROR 
> o.a.m.s.w.webxml.WebXmlParser - Unable to parse web.xml
> java.lang.IllegalArgumentException: The resource path 
> [file:///WEB-INF/webxml/context-params.xml] is not valid
> {code}
> The solution is to remove the file:// prefix before passing to the external 
> context to resolve, as in this patch:
> {code}
> Index: org/apache/myfaces/shared_impl/webapp/webxml/WebXmlParser.java
> ===================================================================
> --- WebXmlParser.java (revision ???)
> +++ WebXmlParser.java (working copy)
> @@ -138,6 +138,9 @@
>  
>      private InputSource createContextInputSource(String publicId, String 
> systemId)
>      {
> +        if(systemId.startsWith("file:")) {
> +            systemId = systemId.substring(7); // remove file://
> +        }
>          InputStream inStream = _context.getResourceAsStream(systemId);
>          if (inStream == null)
>          {
> {code}
> Those three lines of code are based on other work by the MyFaces team 
> (org.apache.myfaces.config.impl.FacesConfigEntityResolver) and even if it 
> weren't is made available free of charge and free from license restrictions.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to