-
Bug
-
Resolution: Done
-
Minor
-
3.0.4.Final
-
None
-
None
Running a test that's using weld-junit4 to initialize the CDI container triggers this exception:
java.lang.NullPointerException at org.jboss.weld.xml.BeansXmlParser.merge(BeansXmlParser.java:87) at org.jboss.weld.xml.BeansXmlParser.mergeExisting(BeansXmlParser.java:122) at org.jboss.weld.environment.deployment.WeldBeanDeploymentArchive.merge(WeldBeanDeploymentArchive.java:142) at org.jboss.weld.environment.se.Weld.createDeployment(Weld.java:978) at org.jboss.weld.environment.se.Weld.initialize(Weld.java:773) at org.jboss.weld.junit.AbstractWeldInitiator.initWeldContainer(AbstractWeldInitiator.java:495) at org.jboss.weld.junit4.WeldInitiator.access$300(WeldInitiator.java:90) at org.jboss.weld.junit4.WeldInitiator$1.evaluate(WeldInitiator.java:226) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
The test itself is incorrect (I was just trying to add the inner class DummyDao to the CDI context), but I don't think the NPE should be thrown anyway.
To fix the test, marking the constructor of DummyDao with @Inject and removing the call .addBeanClass(DummyDao.class) is enough.