Scenario
-
A WAR with weld-servlet-core is deployed to an embedded servlet container (e.g. Tomcat 8).
-
The WAR is assembled on the fly (e.g. with ShrinkWrap), including a library mylib.jar from the classpath with a META-INF/beans.xml descriptor ending up in WEB-INF/lib inside the war.
Problem
The WAR fails to deploy with a WELD-001409: Ambiguous dependencies exception. All beans from mylib.jar are duplicate.
Analysis
WebAppBeanArchiveScanner scans for META-INF/beans.xml using WeldResourceLoader. The resource from mylib.jar is found twice, once on the original system classloader, and again via the web app classloader from WEB-INF/lib/mylib.jar.
Possible solution
WebAppBeanArchiveScanner should ignore any beans.xml descriptors that are not packaged in the WAR.
|