I have been assigned to unit-test a smaller j2ee-application and when researching this I came across Embedded JBoss. Am I certainly not a JBoss-expert but during the ongoing research I have learnt a lot of things about J2EE and Jboss and using Embedded JBoss makes the unit-testing of EJB3 components go smooth.
I have got most of the application working on Embedded JBoss during the research but I have now stumbled across a problem that I have difficulties solving.
The application is being bootstrapped with several Mbeans and this is working fine, but when one of the Mbeans is calling a method on a stateless session bean in its start()-method I get an IndexOutOfBoundsException.
What happens is that the Bootstrap-MBean is using dependency-injection with the @EJB-annotation to reach the stateless session bean, and this stateless session bean is using setter dependency injection with the @Depends annotation to be injected with another MBean. It is this injection that fails.
@Depends(CoreServiceLocator.MBEAN_EVENT_SUBSCRIBER) public void setEventSubscriber(EventSubscriber subscriber) { this.eventSubscriber = subscriber; }
MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);