[ 
https://issues.apache.org/jira/browse/DELTASPIKE-782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14214065#comment-14214065
 ] 

John D. Ament commented on DELTASPIKE-782:
------------------------------------------

[~struberg] here's a link that includes instructions on what to run.  
https://issues.apache.org/jira/browse/DELTASPIKE-782?focusedCommentId=14213993&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14213993
The following show maven commands to execute: 
https://issues.apache.org/jira/browse/DELTASPIKE-782?focusedCommentId=14213963&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14213963

The problem is that tomcat (in this particular case) is creating a webapp 
classloader, so when the servlet tries to load a bean manager it's not found 
within that classloader's context.  It's in the parent.  It looks like there's 
a bug though with the newly created parent classloader resolver.

[~romain.manni-bucau] is generally on the right track.  My _"hack"_ is to 
refactor BeanManagerProvider to add a case for using 
CdiContainerLoader.getCdiContainer().getBeanManager() to find the appropriate 
one, which should fix this case.  My refactoring is to help clean up the hack 
with CDI.current() that exists.  This would avoid classloaders, but still be 
portable cross container.


> BeanManager lookup fails when BeanManager created in parent classloader and 
> in SE mode
> --------------------------------------------------------------------------------------
>
>                 Key: DELTASPIKE-782
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-782
>             Project: DeltaSpike
>          Issue Type: Bug
>          Components: CdiControl, Core
>    Affects Versions: 1.1.0
>            Reporter: Shay matasaro
>            Assignee: John D. Ament
>
> using embeadded tomcat and CdiServletContextListener attempting to use 
> BeanProvider from within a Servlet fails:
> ov 16, 2014 8:19:10 AM org.apache.catalina.core.StandardWrapperValve invoke
> SEVERE: Servlet.service() for servlet [YourServlet] in context with path [/] 
> threw exception
> java.lang.IllegalStateException: Unable to find BeanManager. Please ensure 
> that you configured the CDI implementation of your choice properly.
>       at 
> org.apache.deltaspike.core.api.provider.BeanManagerProvider.getBeanManager(BeanManagerProvider.java:201)
>       at 
> org.apache.deltaspike.core.api.provider.BeanProvider.getBeanManager(BeanProvider.java:475)
>       at 
> org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:118)
>       at 
> org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:101)
> The following code resolves fine in the same location:
> BeanManager beanManager = 
> CdiContainerLoader.getCdiContainer().getBeanManager();
> looks like bmi.loadTimeBm at BeanManagerProvider is not being set properly 
> when using the servlet listener



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to