CDI UserTransaction Injection on SwitchYardRunner based test
edevera Oct 16, 2012 9:11 AMI have the following stack trace when trying to execute a test that involves a BeanService that injects an EJB that injects a UserTransaction (the code works deployed on a JBoss but the test doesn't):
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [UserTransaction] with qualifiers [@Default] at injection point [[field] @Inject private com.my.dataservices.producers.basic.itop.impl.daos.AbstractItopDao.userTransaction] at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:305) at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:139) at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:162) at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:385) at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:371) at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:390) at org.jboss.weld.environment.se.Weld.initialize(Weld.java:88) at org.switchyard.test.mixins.CDIMixIn.initialize(CDIMixIn.java:60) at org.switchyard.test.SwitchYardTestKit.initializeMixIns(SwitchYardTestKit.java:660) at org.switchyard.test.SwitchYardTestKit.<init>(SwitchYardTestKit.java:163) at org.switchyard.test.SwitchYardRunner.createTest(SwitchYardRunner.java:55) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.switchyard.test.SwitchYardRunner.run(SwitchYardRunner.java:79) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [UserTransaction] with qualifiers [@Default] at injection point [[field] @Inject private com.my.dataservices.producers.basic.itop.impl.daos.AbstractItopDao.userTransaction] at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:305) at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:139) at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:162) at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:385) at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:371) at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:390) at org.jboss.weld.environment.se.Weld.initialize(Weld.java:88) at org.switchyard.test.mixins.CDIMixIn.initialize(CDIMixIn.java:60) at org.switchyard.test.SwitchYardTestKit.initializeMixIns(SwitchYardTestKit.java:660) at org.switchyard.test.SwitchYardTestKit.<init>(SwitchYardTestKit.java:163) at org.switchyard.test.SwitchYardRunner.createTest(SwitchYardRunner.java:55) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.switchyard.test.SwitchYardRunner.run(SwitchYardRunner.java:79) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [UserTransaction] with qualifiers [@Default] at injection point [[field] @Inject private com.my.dataservices.producers.basic.itop.impl.daos.AbstractItopDao.userTransaction] at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:305) at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:139) at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:162) at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:385) at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:371) at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:390) at org.jboss.weld.environment.se.Weld.initialize(Weld.java:88) at org.switchyard.test.mixins.CDIMixIn.initialize(CDIMixIn.java:60) at org.switchyard.test.SwitchYardTestKit.initializeMixIns(SwitchYardTestKit.java:660) at org.switchyard.test.SwitchYardTestKit.<init>(SwitchYardTestKit.java:163) at org.switchyard.test.SwitchYardRunner.createTest(SwitchYardRunner.java:55) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.switchyard.test.SwitchYardRunner.run(SwitchYardRunner.java:79) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [UserTransaction] with qualifiers [@Default] at injection point [[field] @Inject private com.my.dataservices.producers.basic.itop.impl.daos.AbstractItopDao.userTransaction] at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:305) at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:139) at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:162) at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:385) at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:371) at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:390) at org.jboss.weld.environment.se.Weld.initialize(Weld.java:88) at org.switchyard.test.mixins.CDIMixIn.initialize(CDIMixIn.java:60) at org.switchyard.test.SwitchYardTestKit.initializeMixIns(SwitchYardTestKit.java:660) at org.switchyard.test.SwitchYardTestKit.<init>(SwitchYardTestKit.java:163) at org.switchyard.test.SwitchYardRunner.createTest(SwitchYardRunner.java:55) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.switchyard.test.SwitchYardRunner.run(SwitchYardRunner.java:79) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
The tests looks like this:
... @RunWith(SwitchYardRunner.class) @SwitchYardTestCaseConfig( config = SwitchYardTestCaseConfig.SWITCHYARD_XML, mixins = { CDIMixIn.class, HornetQMixIn.class, TransactionMixIn.class } ) public class CmdbIT { private SwitchYardTestKit testKit; @ServiceOperation("DataService.save") private Invoker saveCmdbInvoker; @ServiceOperation("DataService.update") private Invoker updateCmdbInvoker; private MockHandler mockADataService; private MockHandler mockBDataService; @Before public void setUp() { mockADataService = testKit.registerInOnlyService("iTopHostDataService"); mockBDataService = testKit.registerInOnlyService("iTopDeploymentDataService"); } ... }