-
Bug
-
Resolution: Done
-
Critical
-
1.1.2.Final
-
None
-
None
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:
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! } ... } ... }
Here's what's happens with this input:
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
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):
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 ...
For more info, see this gist: https://gist.github.com/1180446
- relates to
-
WELD-714 URLScanner parses the same beans.xml file if beans.xml is in WEB-INF/classes/META-INF in a WAR package
-
- Closed
-