[arquillian-issues] [JBoss JIRA] (ARQ-1943) Deployment fails with WELD >= 2.2.5.Final because of duplicate CDI beans when beans inside a dependent JAR.

Chris Rankin (JIRA) issues at jboss.org
Sat Apr 18 19:16:18 EDT 2015


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

Chris Rankin edited comment on ARQ-1943 at 4/18/15 7:15 PM:
------------------------------------------------------------

I've been experimenting with the versions of various dependencies inside my example project, and I have discovered that Arquillian works fine with WELD <= 2.2.4.Final:
{code}
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/chris/.m2/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/chris/Programs/omnifone/arquillian-test/test-servlet/target/tomcat7-embedded/webapps/ROOT/WEB-INF/lib/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
00:05:43.774 localhost-startStop-1 INFO o.j.w.e.s.EnhancedListener - Initialize Weld using ServletContainerInitializer
00:05:43.795 localhost-startStop-1 INFO org.jboss.weld.Version - WELD-000900: 2.2.4 (Final)
00:05:43.962 localhost-startStop-1 INFO org.jboss.weld.Bootstrap - WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
00:05:44.085 localhost-startStop-1 WARN org.jboss.weld.Interceptor - WELD-001700: Interceptor annotation class javax.ejb.PostActivate not found, interception based on it is not enabled
00:05:44.086 localhost-startStop-1 WARN org.jboss.weld.Interceptor - WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled
00:05:44.291 localhost-startStop-1 INFO o.j.w.e.tomcat.TomcatContainer - Tomcat 7+ detected, CDI injection will be available in Servlets, Filters and Listeners.
00:05:44.437 localhost-startStop-1 INFO o.j.w.e.servlet.Listener - org.jboss.weld.environment.servlet.EnhancedListener used for ServletContext notifications
00:05:44.437 localhost-startStop-1 INFO o.j.w.e.s.EnhancedListener - org.jboss.weld.environment.servlet.Listener used for ServletRequest and HttpSession notifications
Apr 19, 2015 12:05:44 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /home/chris/Programs/omnifone/arquillian-test/test-servlet/target/tomcat7-embedded/webapps/ROOT.war has finished in 1,582 ms
00:05:45.964 http-bio-8084-exec-9 INFO org.testing.web.TroubleServlet - Look: Here comes trouble!
event: org.jboss.arquillian.container.spi.event.container.BeforeStop at 51a42578
d: _DEFAULT_
{code}
The problem appears with WELD >= 2.2.5.Final:
{code}
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/chris/.m2/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/chris/Programs/omnifone/arquillian-test/test-servlet/target/tomcat7-embedded/webapps/ROOT/WEB-INF/lib/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
00:10:14.508 localhost-startStop-1 INFO o.j.w.e.servletWeldServlet - WELD-ENV-001008: Initialize Weld using ServletContainerInitializer
00:10:14.521 localhost-startStop-1 INFO org.jboss.weld.Version - WELD-000900: 2.2.5 (Final)
00:10:14.537 localhost-startStop-1 INFO org.jboss.weld.Bootstrap - WELD-ENV-000020: Using jandex for bean discovery
00:10:14.613 localhost-startStop-1 WARN o.j.w.e.servletWeldServlet - WELD-ENV-001004: Found both WEB-INF/beans.xml and WEB-INF/classes/META-INF/beans.xml. It's not portable to use both locations at the same time. Weld is going to use jndi:/localhost/WEB-INF/beans.xml.
00:10:14.709 localhost-startStop-1 INFO org.jboss.weld.Bootstrap - WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
00:10:14.799 localhost-startStop-1 WARN org.jboss.weld.Interceptor - WELD-001700: Interceptor annotation class javax.ejb.PostActivate not found, interception based on it is not enabled
00:10:14.800 localhost-startStop-1 WARN org.jboss.weld.Interceptor - WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled
00:10:14.951 localhost-startStop-1 INFO o.j.w.e.servletTomcat - WELD-ENV-001100: Tomcat 7+ detected, CDI injection will be available in Servlets, Filters and Listeners.
00:10:15.096 localhost-startStop-1 INFO o.j.w.e.servletWeldServlet - WELD-ENV-001006: org.jboss.weld.environment.servlet.EnhancedListener used for ServletContext notifications
00:10:15.096 localhost-startStop-1 INFO o.j.w.e.servletWeldServlet - WELD-ENV-001009: org.jboss.weld.environment.servlet.Listener used for ServletRequest and HttpSession notifications
Apr 19, 2015 12:10:15 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Trouble as unavailable
Apr 19, 2015 12:10:15 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet  threw load() exception
org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type String with qualifiers @Trouble
  at injection point [BackedAnnotatedField] @Trouble @Inject private org.testing.web.TroubleServlet.trouble
  at org.testing.web.TroubleServlet.trouble(TroubleServlet.java:0)
  Possible dependencies: 
  - Producer Method [String] with qualifiers [@Trouble @Any] declared as [[BackedAnnotatedMethod] @Produces @Trouble org.testing.TroubleMaker.getTrouble()],
  - Producer Method [String] with qualifiers [@Trouble @Any] declared as [[BackedAnnotatedMethod] @Produces @Trouble org.testing.TroubleMaker.getTrouble()]
{code}
However, I must stress that Maven's WAR artifact deploys fine with WELD 2.2.5.Final inside Tomcat 7.0.52. It is only the Arquillian deployment which begins to fail.


was (Author: chrisjr):
I've been experimenting with the versions of various dependencies inside my example project, and I have discovered that it works fine with WELD <= 2.2.4.Final:
{code}
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/chris/.m2/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/chris/Programs/omnifone/arquillian-test/test-servlet/target/tomcat7-embedded/webapps/ROOT/WEB-INF/lib/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
00:05:43.774 localhost-startStop-1 INFO o.j.w.e.s.EnhancedListener - Initialize Weld using ServletContainerInitializer
00:05:43.795 localhost-startStop-1 INFO org.jboss.weld.Version - WELD-000900: 2.2.4 (Final)
00:05:43.962 localhost-startStop-1 INFO org.jboss.weld.Bootstrap - WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
00:05:44.085 localhost-startStop-1 WARN org.jboss.weld.Interceptor - WELD-001700: Interceptor annotation class javax.ejb.PostActivate not found, interception based on it is not enabled
00:05:44.086 localhost-startStop-1 WARN org.jboss.weld.Interceptor - WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled
00:05:44.291 localhost-startStop-1 INFO o.j.w.e.tomcat.TomcatContainer - Tomcat 7+ detected, CDI injection will be available in Servlets, Filters and Listeners.
00:05:44.437 localhost-startStop-1 INFO o.j.w.e.servlet.Listener - org.jboss.weld.environment.servlet.EnhancedListener used for ServletContext notifications
00:05:44.437 localhost-startStop-1 INFO o.j.w.e.s.EnhancedListener - org.jboss.weld.environment.servlet.Listener used for ServletRequest and HttpSession notifications
Apr 19, 2015 12:05:44 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /home/chris/Programs/omnifone/arquillian-test/test-servlet/target/tomcat7-embedded/webapps/ROOT.war has finished in 1,582 ms
00:05:45.964 http-bio-8084-exec-9 INFO org.testing.web.TroubleServlet - Look: Here comes trouble!
event: org.jboss.arquillian.container.spi.event.container.BeforeStop at 51a42578
d: _DEFAULT_
{code}
The problem appears with WELD >= 2.2.5.Final:
{code}
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/chris/.m2/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/chris/Programs/omnifone/arquillian-test/test-servlet/target/tomcat7-embedded/webapps/ROOT/WEB-INF/lib/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
00:10:14.508 localhost-startStop-1 INFO o.j.w.e.servletWeldServlet - WELD-ENV-001008: Initialize Weld using ServletContainerInitializer
00:10:14.521 localhost-startStop-1 INFO org.jboss.weld.Version - WELD-000900: 2.2.5 (Final)
00:10:14.537 localhost-startStop-1 INFO org.jboss.weld.Bootstrap - WELD-ENV-000020: Using jandex for bean discovery
00:10:14.613 localhost-startStop-1 WARN o.j.w.e.servletWeldServlet - WELD-ENV-001004: Found both WEB-INF/beans.xml and WEB-INF/classes/META-INF/beans.xml. It's not portable to use both locations at the same time. Weld is going to use jndi:/localhost/WEB-INF/beans.xml.
00:10:14.709 localhost-startStop-1 INFO org.jboss.weld.Bootstrap - WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
00:10:14.799 localhost-startStop-1 WARN org.jboss.weld.Interceptor - WELD-001700: Interceptor annotation class javax.ejb.PostActivate not found, interception based on it is not enabled
00:10:14.800 localhost-startStop-1 WARN org.jboss.weld.Interceptor - WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled
00:10:14.951 localhost-startStop-1 INFO o.j.w.e.servletTomcat - WELD-ENV-001100: Tomcat 7+ detected, CDI injection will be available in Servlets, Filters and Listeners.
00:10:15.096 localhost-startStop-1 INFO o.j.w.e.servletWeldServlet - WELD-ENV-001006: org.jboss.weld.environment.servlet.EnhancedListener used for ServletContext notifications
00:10:15.096 localhost-startStop-1 INFO o.j.w.e.servletWeldServlet - WELD-ENV-001009: org.jboss.weld.environment.servlet.Listener used for ServletRequest and HttpSession notifications
Apr 19, 2015 12:10:15 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Trouble as unavailable
Apr 19, 2015 12:10:15 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet  threw load() exception
org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type String with qualifiers @Trouble
  at injection point [BackedAnnotatedField] @Trouble @Inject private org.testing.web.TroubleServlet.trouble
  at org.testing.web.TroubleServlet.trouble(TroubleServlet.java:0)
  Possible dependencies: 
  - Producer Method [String] with qualifiers [@Trouble @Any] declared as [[BackedAnnotatedMethod] @Produces @Trouble org.testing.TroubleMaker.getTrouble()],
  - Producer Method [String] with qualifiers [@Trouble @Any] declared as [[BackedAnnotatedMethod] @Produces @Trouble org.testing.TroubleMaker.getTrouble()]
{code}
However, I must stress that Maven's WAR artifact deploys fine with WELD 2.2.5.Final inside Tomcat 7.0.52. It is only the Arquillian deployment which begins to fail.

> Deployment fails with WELD >= 2.2.5.Final because of duplicate CDI beans when beans inside a dependent JAR.
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: ARQ-1943
>                 URL: https://issues.jboss.org/browse/ARQ-1943
>             Project: Arquillian
>          Issue Type: Bug
>          Components: Tomcat Containers
>    Affects Versions: tomcat_1.0.0.CR7
>         Environment: Windows 7 x64, Linux x64, JDK7
>            Reporter: Chris Rankin
>         Attachments: arquillian-test.tar.xz
>
>
> Using arquillian-tomcat-embedded-7, arquillian-bom 1.1.7.Final, WELD 2.2.10.Final:
> I have created a simple WAR file that contains WELD and a single servlet. There is also a dependent JAR that contains the following:
> - a @Dependent bean with a @Produces method
> - a META-INF/beans.xml file.
> When I try to test this servlet using Arquillian's TestNG container, the deployment fails with this error:
> SEVERE: Servlet  threw load() exception
> org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type String with qualifiers @Trouble
>   at injection point [BackedAnnotatedField] @Trouble @Inject private org.testing.web.TroubleServlet.trouble
>   at org.testing.web.TroubleServlet.trouble(TroubleServlet.java:0)
>   Possible dependencies: 
>   - Producer Method [String] with qualifiers [@Trouble @Any] declared as [[BackedAnnotatedMethod] @Produces @Trouble org.testing.TroubleMaker.getTrouble()],
>   - Producer Method [String] with qualifiers [@Trouble @Any] declared as [[BackedAnnotatedMethod] @Produces @Trouble org.testing.TroubleMaker.getTrouble()]



--
This message was sent by Atlassian JIRA
(v6.3.11#6341)


More information about the arquillian-issues mailing list