myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Stankiewicz (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Commented] (MYFACES-3580) Searching for JAR in RAR by facelets Claspath util causes FileNotFoundException
Date Fri, 06 Jul 2012 09:50:35 GMT

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

Daniel Stankiewicz commented on MYFACES-3580:
---------------------------------------------

Note also very similar bug of Oracle Mojarra JSF Reference Implementation: http://java.net/jira/browse/JAVASERVERFACES-1869

The code below of analogous class com.sun.faces.facelets.util.Classpath in version 2.0.1 affected
by bug JAVASERVERFACES-1869 is nearly identical to the above MyFaces code:

private static JarFile getAlternativeJarFile(URL url) throws IOException {
        String urlFile = url.getFile();
        // Trim off any suffix - which is prefixed by "!/" on Weblogic
        int separatorIndex = urlFile.indexOf("!/");

        // OK, didn't find that. Try the less safe "!", used on OC4J
        if (separatorIndex == -1) {
            separatorIndex = urlFile.indexOf('!');
        }

        if (separatorIndex != -1) {
            String jarFileUrl = urlFile.substring(0, separatorIndex);
            // And trim off any "file:" prefix.
            if (jarFileUrl.startsWith("file:")) {
                jarFileUrl = jarFileUrl.substring("file:".length());
                jarFileUrl = URLDecoder.decode(jarFileUrl, "UTF-8");
            }
            return new JarFile(jarFileUrl);
        }
        return null;
    }

The code of the same method of 2.0.6 version, where bug JAVASERVERFACES-1869 is fixed, looks
like this:

    // discard any urls that begin with rar: and sar:
    // or end with their counterparts
    // as these should not be looked at for JSF related content.
    private static final String [] PREFIXES_TO_EXCLUDE = {
        "rar:",
        "sar:"
    };
    private static final String [] EXTENSIONS_TO_EXCLUDE = {
        ".rar",
        ".sar"
    };

static JarFile getAlternativeJarFile(String urlFile) throws IOException {
        JarFile result = null;
        // Trim off any suffix - which is prefixed by "!/" on Weblogic
        int bangSlash = urlFile.indexOf("!/");
        // Try the less safe "!", used on OC4J
        int bang = urlFile.indexOf('!');
        int separatorIndex = -1;
        
        // if either are found, take the first one.
        if (-1 != bangSlash || -1 != bang) {
            if (bangSlash < bang) {
                separatorIndex = bangSlash;
            } else {
                separatorIndex = bang;
            }
        }

        if (separatorIndex != -1) {
            String jarFileUrl = urlFile.substring(0, separatorIndex);
            // And trim off any "file:" prefix.
            if (jarFileUrl.startsWith("file:")) {
                jarFileUrl = jarFileUrl.substring("file:".length());
                jarFileUrl = URLDecoder.decode(jarFileUrl, "UTF-8");
            }
            boolean foundExclusion = false;
            for (int i = 0; i < PREFIXES_TO_EXCLUDE.length; i++) {
                if (jarFileUrl.startsWith(PREFIXES_TO_EXCLUDE[i]) ||
                    jarFileUrl.endsWith(EXTENSIONS_TO_EXCLUDE[i])) {
                    foundExclusion = true;
                    break;
                }
            }
            if (!foundExclusion) {
                result = new JarFile(jarFileUrl);
            }

            return result;
        }
        return null;
    }

Note that:
1. The fixed code looks for both separators: ! and !/ and  cuts the URL from the first found
separator to the end.
2. All the URLs prefixed with rar: sar: or suffixed with .rar .sar are ignored.

MyFaces should contain similar code in order to work properly in such scenario.


                
> Searching for JAR in RAR by facelets Claspath util causes FileNotFoundException
> -------------------------------------------------------------------------------
>
>                 Key: MYFACES-3580
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3580
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.13
>         Environment: Oracle Weblogic 10.3.5
> Apache MyFaces 2.0.13
>            Reporter: Daniel Stankiewicz
>            Priority: Critical
>
> We have an EAR which contains a WAR and a RAR (Resource Adapter). The RAR archive contains
a JAR with Resource Adapter classes.
> The problem is that trying to deploy such an EAR in Weblogic 10.3.5 causes a FileNotFoundException
to be thrown.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message