[weld-issues] [JBoss JIRA] Issue Comment Edited: (WELD-958) URLScanner parses the wrong META-INF/beans.xml files if the parent classloader has a META-INF/beans.xml file

Geoffrey De Smet (JIRA) jira-events at lists.jboss.org
Fri Sep 23 03:14:26 EDT 2011


    [ https://issues.jboss.org/browse/WELD-958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12630143#comment-12630143 ] 

Geoffrey De Smet edited comment on WELD-958 at 9/23/11 3:12 AM:
----------------------------------------------------------------

Yes, resolving this issue. Pull request was merged by alesj

      was (Author: ge0ffrey):
    Pull request was merged by alesj
  
> URLScanner parses the wrong META-INF/beans.xml files if the parent classloader has a META-INF/beans.xml file
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: WELD-958
>                 URL: https://issues.jboss.org/browse/WELD-958
>             Project: Weld
>          Issue Type: Bug
>    Affects Versions: 1.1.2.Final
>            Reporter: Geoffrey De Smet
>            Priority: Critical
>             Fix For: 1.2.0.Beta1
>
>
> Note that WELD-714 (fixed for 1.1.0.CR1) does NOT fix this in weld 1.1.2.Final.
> Here's the code that causes the problem:
> {code}
> public class URLScanner
> {
> ...
>    protected void handleArchiveByFile(File file, ...) ...
>    {
>       ...
>          ZipFile zip = new ZipFile(file);
>          Enumeration<? extends ZipEntry> entries = zip.entries();
>          // Replace out the default classloader with one for the zip
>          URLClassLoader classLoader = new URLClassLoader(new URL[] { file.toURI().toURL() }); // PROBLEM PART 1: delegates first to parent classloader
>          while (entries.hasMoreElements())
>          {
>             ZipEntry entry = entries.nextElement();
>             String name = entry.getName();
>             handle(..., classLoader.getResource(name), ...); // PROBLEM PART 2: if parent classloader contains that name, the file content is ignored!
>          }
>       ...
>    }
> ...
> }
> {code}
> Here's what's happens with this input:
> {code}
> file = /tmp/tomcat-embedded-6/work/arquillian-tomcat-embedded-6/localhost/guvnor-webapp-5.3.0-SNAPSHOT/WEB-INF/lib/seam-persistence-api-3.1.0.Beta2.jar
> classLoader = URL is file:/tmp/tomcat-embedded-6/work/arquillian-tomcat-embedded-6/localhost/guvnor-webapp-5.3.0-SNAPSHOT/WEB-INF/lib/seam-persistence-api-3.1.0.Beta2.jar
> for each entry, when:
>   name = "META-INF/beans.xml"
>   classLoader.getResource(name) = file:/home/gdesmet/projects/jboss/forked-guvnor/guvnor-webapp/target/classes/META-INF/beans.xml // WRONG
>   // Should be = .../seam-persistence-api-3.1.0.Beta2.jar!META-INF/beans.xml
> {code}
> As a direct result, URLScanner.handle(...) handles the same wrong META-INF/beans.xml file multiple times (one for each real META-INF/beans.xml):
> {code}
> Handle file META-INF/beans.xml from file:/home/gdesmet/projects/jboss/forked-guvnor/guvnor-webapp/target/classes/META-INF/beans.xml
> Handle file META-INF/beans.xml from file:/home/gdesmet/projects/jboss/forked-guvnor/guvnor-webapp/target/classes/META-INF/beans.xml
> Handle file META-INF/beans.xml from file:/home/gdesmet/projects/jboss/forked-guvnor/guvnor-webapp/target/classes/META-INF/beans.xml
> ...
> {code}
> For more info, see this gist: https://gist.github.com/1180446

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the weld-issues mailing list