JBoss AS BeanManager not found
mcgin Nov 27, 2011 1:20 PMFor some reason I cannot get dependency injection to work with Arquillian. I've devised a very simple test just to see if injection is working and I'm getting "BeanManager not found" output in the server logs which presumably is the root of the NullPointerException.
Relevant info attached below, I presume I'm just missing something very basic here!
Test case:
{code}
@RunWith(Arquillian.class)
public class ServiceTest {
private static final Logger logger = LoggerFactory.getLogger(ServiceTest.class);
@Deployment
public static Archive<?> createTestArchive() {
return ShrinkWrap.create(WebArchive.class, "test.war")
.addAsManifestResource("test-jboss-deployment-structure.xml","jboss-deployment-structure.xml")
.addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addClass(Injectable.class)
;
}
@Inject
private Injectable injectable;
@Test
public void testCanPersistLocationObject() {
logger.info("RUNNING THE TEST");
logger.info(injectable.injectMe()); //This is throwing a null pointer exception
}
}
{code}
Injectable.java
{code}
@Stateless
public class Injectable {
public String injectMe() {
return "I was injected";
}
}
{code}
Arquillian Dependencies
{code}
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-remote</artifactId>
<version>${jbossas.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>{code}
Server logs:
{code}
17:56:41,300 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "test.war"
17:56:41,353 INFO [org.jboss.as.jpa] (MSC service thread 1-1) added javax.persistence.api dependency to test.war
17:56:41,363 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI
bindings for session bean named Injectable in deployment unit deployment "test.war" are as follows:
java:global/test/Injectable!service.Injectable
java:app/test/Injectable!service.Injectable
java:module/Injectable!service.Injectable
java:global/test/Injectable
java:app/test/Injectable
java:module/Injectable
17:56:41,383 INFO [org.jboss.as.arquillian] (MSC service thread 1-1) Arquillian deployment detected: ArquillianConfig[service=jb
ss.arquillian.config."test.war",unit=test.war,tests=[service.ServiceTest]]
17:56:41,395 INFO [org.jboss.web] (MSC service thread 1-3) registering web context: /test
17:56:41,405 INFO [org.jboss.as.server.controller] (pool-1-thread-23) Deployed "test.war"
17:56:41,610 INFO [org.jboss.arquillian.testenricher.cdi.container.BeanManagerProducer] (RMI TCP Connection(42)-127.0.0.1) BeanM
nager not found.
17:56:41,617 INFO [com.gamblerstools.bettingbot.service.BetbotServiceTest] (RMI TCP Connection(42)-127.0.0.1) RUNNING THE TEST
17:56:41,621 ERROR [org.jboss.arquillian.protocol.jmx.JMXTestRunner] (RMI TCP Connection(42)-127.0.0.1) Failed: service.ServiceTest.testCanPersistLocationObject: java.lang.NullPointerException
{code}