-
1. Re: BeanManager method getBeans() is not available during application initialization
luksa Jul 20, 2013 4:59 PM (in response to alberto_souza)You have an extension that calls beanManager.getBeans() before the system is fully initialized.
See the javadoc of BeanManager.getBeans():
@throws IllegalStateException if called during application initialization, before the {@link AfterDeploymentValidation}
event is fired The container is permitted to define a non-portable mode in which {@link #getBeans(String)} may be
called from an observer of the {@link AfterBeanDiscovery} event.
You should move the call to an @Observers AfterDeploymentValidation event method. If you truly must call this method before, you should enable non-portable mode. In Weld, you can enable it with -Dorg.jboss.weld.nonPortableMode=true
However, if you call the method before the system is fully initialized, there is a chance beanManager will not return correct information.
-
2. Re: BeanManager method getBeans() is not available during application initialization
alberto_souza Jul 20, 2013 6:07 PM (in response to luksa)Hi, i do not call getBeans inside extensions... I know that is not portable... And, as i said, when i run just one test, everything goes fine
-
3. Re: BeanManager method getBeans() is not available during application initialization
luksa Jul 20, 2013 6:28 PM (in response to alberto_souza)Wait, so you mean you have -Dorg.jboss.weld.nonPortableMode=true ? If you do, you should not get the exception.
If you don't, getBeans() obviously is not called in that test or you are calling it in @Observes AfterDeploymentValidation or later.
-
4. Re: BeanManager method getBeans() is not available during application initialization
alberto_souza Jul 20, 2013 6:50 PM (in response to luksa)Sorry Marko, but i am not calling getBeans() inside any extension and i am not using the weld nonPortableMode. I invoke getBeans() only after the container is initialized... Maybe there is something else going on... I am invesgating...
-
5. Re: BeanManager method getBeans() is not available during application initialization
luksa Jul 20, 2013 6:52 PM (in response to alberto_souza)Oh, sorry, I misread your previous comment (I thought you said "I DO call getBeans" ).
Well, if you get the exception, you can see who's calling getBeans() from the stacktrace, can't you?
-
6. Re: BeanManager method getBeans() is not available during application initialization
alberto_souza Jul 20, 2013 7:03 PM (in response to luksa)Yes i can. The getBeans is being called after the container is initialized... I am missing the point... Because the same test that fails when is executed with others, is passing when is executed alone...
-
7. Re: BeanManager method getBeans() is not available during application initialization
luksa Jul 20, 2013 7:23 PM (in response to alberto_souza)Check what state the container is in when it throws the exception.
If the single test passes when run alone, I can only assume that you have some sort of init/shutdown problem.
Are you bootstraping the container in every test?
-
8. Re: BeanManager method getBeans() is not available during application initialization
luksa Jul 22, 2013 7:00 AM (in response to luksa)You are probably calling getBeans() after shutdown (I've created https://issues.jboss.org/browse/WELD-1466)
-
9. Re: BeanManager method getBeans() is not available during application initialization
alberto_souza Jul 22, 2013 8:52 AM (in response to luksa)I think you are right!!!. I've put some logs and the messages indicate this scenario... It is strange... i have a @AfterClass method that is being called before the end of tests...