<div dir="ltr">I&#39;m running into a really strange behaviour, and I&#39;m not entirely sure where/how to start looking for this or if it is something that I can easily reproduce in a test case (or if it is even worthwhile).<div><br></div><div>I&#39;ve got a mutil-war JEE EAR application that uses EJBs, Struts1.  and Struts2.</div><div><br></div><div>My EAR is as follows:</div><div>EAR</div><div> - root.war</div><div> - ejb.jar</div><div> - web.war</div><div> - ws.war</div><div> - lib/common jars<br></div><div><br></div><div><br></div><div>In one of my war1 web filters, I am sucessfully able to retrieve a bean from the CDI using:</div><div><div>         SessionManager sessionManager = CDI.current().select(SessionManager.class).get()</div></div><div><br></div><div>However, in a Struts1 action, I&#39;m trying to retrieve the same bean from the CDI using:</div><div><div>         SessionManager sessionManager = CDI.current().select(SessionManager.class).get()</div></div><div><br></div><div>but WELD throws and error that it is unable to resolve the SessionManager bean:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308: Unable to resolve any beans for Type: interface webapp.session.SessionManager; Qualifiers: []</div></blockquote><div><br></div><div><br></div><div>When I dig more into it, I see that CDI.current().getBeanManager() in the filter always returns the beanManager for my ear/web.war deployment.  However, when trying the same call in my Struts 1 Action, instead, it will at times retrieve the bean manager for other deployments, seemingly randomly:</div><div>- ear/root.war</div><div>- ear/ws.war</div><div>- ear/ejb.jar</div><div>- ear/web.war</div><div><br></div><div>If I retrieve the BeanManager manually from the JNDI, using a JNDI lookup, I am able to retrieve the bean without problems:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>BeanManager beanManager = (BeanManager) new InitialContext().lookup(&quot;java:comp/BeanManager&quot;);</div></div><div><div>Set&lt;Bean&lt;?&gt;&gt; 
beans = beanManager.getBeans(SessionManager.class);</div></div><div><div>Bean&lt;?&gt; bean = 
beanManager.resolve(beans);</div></div><div><div>CreationalContext&lt;?&gt; context = 
beanManager.createCreationalContext(bean);</div></div><div><div>SessionManager sessionManager = 
(SessionManager) beanManager.getReference(bean, SessionManager.class, 
context);</div></div></blockquote><div><br></div><div><br></div><div><br></div><div>So at the end, I&#39;m not entirely sure why CDI.current().getBeanManager() would be retrieving the BeanManager from a different context.  Might this be a bug in Weld, a problem in the container, or something strange that is happening due to the way that Struts1 was designed?  Or do I need to do/add something specific to a config to enable CDI access from within a servlet?</div><div><br></div><div>Struts1 is launched as a servlet in the web.xml:</div><div><div>   &lt;servlet&gt;</div><div>      &lt;servlet-name&gt;action&lt;/servlet-name&gt;</div><div>      &lt;servlet-class&gt;org.apache.struts.action.ActionServlet&lt;/servlet-class&gt;<br></div><div>      &lt;init-param&gt;</div><div>         &lt;param-name&gt;config&lt;/param-name&gt;</div><div>         &lt;param-value&gt;/WEB-INF/struts-config.xml&lt;/param-value&gt;</div><div>      &lt;/init-param&gt;</div><div>      &lt;init-param&gt;<br></div><div>         &lt;param-name&gt;chainConfig&lt;/param-name&gt;</div><div>         &lt;param-value&gt;/WEB-INF/chain-config.xml&lt;/param-value&gt;<br></div><div>      &lt;/init-param&gt;<br></div><div>      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;</div><div>   &lt;/servlet&gt;</div></div><div><br></div><div><br></div><div><br></div><div>Thanks!</div><div><br></div><div>Eric</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>