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

Sean Flanigan commented on DELTASPIKE-1198:
-------------------------------------------

[~johndament] I suppose by "bean val 1.1" you meant 
[this|https://rmannibucau.wordpress.com/2013/07/02/bean-validation-1-1/] rather 
than this [Bean 
Validation|https://deltaspike.apache.org/documentation/bean-validation.html]. 

In the case of Hibernate Validator, I think InjectingConstraintValidatorFactory 
still insists on a live BeanManager, so I would still need to avoid using it in 
my non-CDI tests.

However, unless I write my own CDI extension (and ensure that CDI-Unit picks it 
up), I'm not sure how to detect whether CDI is currently active from a 
ConstraintValidatorFactory, if I can't rely on BeanManagerProvider.isActive(). 
(BeanManagerProvider almost seems to be that CDI extension already.)

For now, my only workaround is to call {{BeanManagerProvider.isActive()}} then 
double check with 
{{BeanManagerProvider.getInstance().getBeanManager().getBeans()}} catching 
{{IllegalStateException}}, which is of course not very pretty.


> BeanManagerProvider.isActive() returns true after container shutdown
> --------------------------------------------------------------------
>
>                 Key: DELTASPIKE-1198
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1198
>             Project: DeltaSpike
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.7.0, 1.7.2
>            Reporter: Sean Flanigan
>
> While trying to implement DELTASPIKE-1197 I found that 
> {{BeanManagerProvider.isActive()}} returns true after container shutdown.
> The javadocs for {{isActive()}} say "@return true if the BeanManagerProvider 
> is ready to be used", but when it is in this state, the BeanManagerProvider 
> can't actually be used because the CDI container is not active. 
> In the case of Weld, when {{BeanProvider.getContextualReference()}} was 
> called I got errors like "java.lang.IllegalStateException: Singleton not set 
> for STATIC_INSTANCE => []". There was no stack trace, but that message comes 
> from Weld's RegistrySingletonProvider.java.
> It would seem reasonable to reset bmpSingleton to null during 
> cleanupStoredBeanManagerOnShutdown, but for some reason this breaks a lot of 
> tests.



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

Reply via email to