I've an standard web project built in Eclipse. My project makes uses of weld and my beans.xml is placed at the following location: build/classes/META-INF/beans.xml
When I try to start Tomcat, the following exception is thrown:java.lang.IllegalStateException: *_WELD-ENV-000033: Invalid bean archive scanning result - found multiple results with the same reference: /home/openbravo/src/weld/pi-weld-upgrade/build/classes_* (Attached you can find the complete stack trace)
The problem is caused because the [WebAppBeanArchiveScanner|https://github.com/weld/core/blob/master/environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/deployment/WebAppBeanArchiveScanner.java] is finding my beans.xml file twice:
1) When invoking the scan method of the parent [DefaultBeanArchiveScanner|https://github.com/weld/core/blob/master/environments/common/src/main/java/org/jboss/weld/environment/deployment/discovery/DefaultBeanArchiveScanner.java#L75] class when looking for the META-INF/beans.xml
2) By the WebAppBeanArchiveScanner itself when looking for the /WEB-INF/classes/META-INF/beans.xml. See [here|https://github.com/weld/core/blob/master/environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/deployment/WebAppBeanArchiveScanner.java#L103].
This is causing that Tomcat can not be started using Eclipse. This problem can be reproduced using Tomcat 8, 8.5 and 9.
Note 1: with this the same project structure and location of the beans.xml file, and using and older version of weld (I've tried with 1.1.24) Tomcat 8, 8.5 and 9 start without trouble.
Note 2: this problem usually does not happen when deploying the context applicaton in Tomcat without using Eclipse. In this case the beans.xml file is placed at WEB-INF/classes/META-INF/beans.xml. As this path contains the keyword "WEB-INF" the result found by the DefaultBeanArchiveScanner is discarded [here|https://github.com/weld/core/blob/master/environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/deployment/WebAppBeanArchiveScanner.java#L80].
|
|