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

Geoffrey De Smet commented on WELD-958:
---------------------------------------

Here's a pull request with the fix for that issue: 
https://github.com/weld/core/pull/130

> 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
>
> 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

        
_______________________________________________
weld-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/weld-issues

Reply via email to