[jira] [Commented] (DELTASPIKE-1198) BeanManagerProvider.isActive() returns true after container shutdown
[ https://issues.apache.org/jira/browse/DELTASPIKE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16606991#comment-16606991 ] ASF subversion and git services commented on DELTASPIKE-1198: - Commit 20ba0e9f7d0c944885092bafb85f3df51b8ed7df in deltaspike's branch refs/heads/master from [~struberg] [ https://git-wip-us.apache.org/repos/asf?p=deltaspike.git;h=20ba0e9 ] DELTASPIKE-1198 check if the _current_ beanManager is still attached. This will deal with shutting down the container > 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 >Assignee: Mark Struberg >Priority: Major > Fix For: 1.9.0 > > > 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 (v7.6.3#76005)
[jira] [Commented] (DELTASPIKE-1198) BeanManagerProvider.isActive() returns true after container shutdown
[ https://issues.apache.org/jira/browse/DELTASPIKE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16001886#comment-16001886 ] Sean Flanigan commented on DELTASPIKE-1198: --- [~struberg] I'm afraid I'm a bit rusty on this code by now, but in my own project I have a test suite which uses CDI-Unit (based on Weld SE) along with plain (non-CDI) unit tests, trying to use CDIAwareConstraintValidatorFactory in both environments, which is why I needed DELTASPIKE-1197. See my changes in https://github.com/apache/deltaspike/compare/master...seanf:DELTASPIKE-1197 ( https://issues.apache.org/jira/browse/DELTASPIKE-1197?focusedCommentId=15431960=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15431960 ) I think it was accessing the {{BeanManager}} via {{bmpSingleton}} (which is static). As I said in the description, it would be good to null it out at shutdown, but when I tried that I found that it broke a number of DeltaSpike's tests. I can't reproduce those test failures now, but as I said, I'm a bit rusty on this. Anyway, I suppose the real problem is that {{isActive}} is that it doesn't agree with {{cleanupStoredBeanManagerOnShutdown}}, since the cleanup method just removes things from a map, but {{isActive}} doesn't look inside that map. If for some reason {{bmpSingleton}} can't be set to null, what if {{isActive}} were something like this? {code:java} public static boolean isActive() { return bmpSingleton != null && bmpSingleton.bmInfos.containsKey(ClassUtils.getClassLoader(null)); } {code} > 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 >Assignee: Mark Struberg > > 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.15#6346)
[jira] [Commented] (DELTASPIKE-1198) BeanManagerProvider.isActive() returns true after container shutdown
[ https://issues.apache.org/jira/browse/DELTASPIKE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16000764#comment-16000764 ] Mark Struberg commented on DELTASPIKE-1198: --- Seems we do it properly. See cleanupStoredBeanManagerOnShutdown. There we remove the BeanManager from the Map again. Not sure how you manage to access the BeanManager after shutdown. How does your project setup look like? > 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 >Assignee: Mark Struberg > > 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.15#6346)
[jira] [Commented] (DELTASPIKE-1198) BeanManagerProvider.isActive() returns true after container shutdown
[ https://issues.apache.org/jira/browse/DELTASPIKE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16000761#comment-16000761 ] Mark Struberg commented on DELTASPIKE-1198: --- I've reviewed this and I interpret BeanManagerProvider#isActive() a bit different. It returns true if the BMP got initialised. But having the BeanManagers itself is something different. We might probably not unload the BeanManagers properly, which would be a problem. Investigating. > 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 >Assignee: Mark Struberg > > 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.15#6346)
[jira] [Commented] (DELTASPIKE-1198) BeanManagerProvider.isActive() returns true after container shutdown
[ https://issues.apache.org/jira/browse/DELTASPIKE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15434950#comment-15434950 ] Sean Flanigan commented on DELTASPIKE-1198: --- [~johndament] The validators themselves aren't terribly complex - at worst, they might just use a DAO to check for a duplicate email address. But I do have a mix of very simple validators which don't even need mocks to test, and other validators like the duplicate email validator which need injection of things like DAOs. Switching them all to CDI tests would get around the problem, but that's quite a bit of work, especially for any tests which already needed a custom JUnit Runner. I don't know how to tell Hibernate to use a non-CDI ConstraintValidatorFactory for simple unit tests, and use CdiAwareConstraintValidatorFactory or InjectingConstraintValidatorFactory for the others, so the next best thing would be a ConstraintValidatorFactory which chooses between them, depending on the state of CDI. BeanManagerProvider is generally a really handy class for low-level CDI stuff like getting a BeanManager, so it's a shame {{isActive()}} can't be used for this. I'm not using Test-Control, but I am using CDI-Unit, together with Weld SE, which does a lot of the same things. From what I can tell, it is shutting down the Weld deployment between tests, at least enough to blow up when BeanManagerProvider tries to use it. The weird thing is that the class BeanManagerProvider is retaining a static reference to a object which were created by the first Weld container (including an instance of BeanManagerProvider itself, which holds a BeanManager), even after that container has stopped. That doesn't cause a problem most of the time (except a minor memory leak on shutdown perhaps), but it does cause {{isActive()}} to violate its own javadoc IMHO. Have you got any idea why the BeanManagerProvider needs to retain state after container shutdown? > 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)
[jira] [Commented] (DELTASPIKE-1198) BeanManagerProvider.isActive() returns true after container shutdown
[ https://issues.apache.org/jira/browse/DELTASPIKE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15432025#comment-15432025 ] John D. Ament commented on DELTASPIKE-1198: --- Sean, I was wondering what your use case is. This is a feature of bean val 1.1, so we don't really maintain it anymore. How are you using it? What are you deploying to? > 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)
[jira] [Commented] (DELTASPIKE-1198) BeanManagerProvider.isActive() returns true after container shutdown
[ https://issues.apache.org/jira/browse/DELTASPIKE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15432019#comment-15432019 ] Sean Flanigan commented on DELTASPIKE-1198: --- FWIW, I was able to reconstruct the stack trace in the debugger: {noformat} java.lang.IllegalStateException: Singleton not set for STATIC_INSTANCE => [] at org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider$RegistrySingleton.get(RegistrySingletonProvider.java:28) at org.jboss.weld.Container.instance(Container.java:65) at org.jboss.weld.Container.instance(Container.java:69) at org.jboss.weld.bean.builtin.BeanManagerProxy.checkContainerState(BeanManagerProxy.java:234) at org.jboss.weld.bean.builtin.BeanManagerProxy.checkContainerState(BeanManagerProxy.java:247) at org.jboss.weld.bean.builtin.BeanManagerProxy.getBeans(BeanManagerProxy.java:96) at org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:144) at org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:121) at org.apache.deltaspike.beanvalidation.impl.CDIAwareConstraintValidatorFactory.getInstance(CDIAwareConstraintValidatorFactory.java:61) at org.zanata.test.TestingConstraintValidatorFactory.getInstance(TestingConstraintValidatorFactory.java:54) ... {noformat} (Weld SE 2.3.2.Final, DeltaSpike 1.7.0) NB: TestingConstraintValidatorFactory simply checks BeanManagerProvider.isActive() before calling CDIAwareConstraintValidatorFactory.getInstance(). > 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)