[GLASSFISH-19043] habitat is coming as null Created: 29/Aug/12  Updated: 20/Dec/16  Resolved: 11/Feb/13

Status: Closed
Project: glassfish
Component/s: hk2
Affects Version/s: 4.0_dev
Fix Version/s: None

Type: Bug Priority: Major
Reporter: naman_mehta Assignee: naman_mehta
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified



When I tried to get the habitat it's coming as null during Junit test run.

Habitat habitat = Globals.getDefaultHabitat();
if(habitat == null) return;

In normal scenario with server is up then there is no issue. i am getting habitat correctly.

Comment by jwells [ 13/Dec/12 ]

Is there a reproducer for this?

If you try to use Globals before the Habitat has been created then getDefaultHabitat will return null.

If you are doing unit testing with the new hk2 you might want to look into using the HK2Runner and simply inject the ServiceLocator into your test code.

If you think this truly should work, then provide a reproducer please. Thanks!

Generated at Wed Mar 22 23:31:38 UTC 2017 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.