Starting JBossAS automatically

Version 4

    You can run your tests against local JBossAS6* for example by starting server first and running tests against it afterwards. Arquillian detects, if server has been started. That's fast and fine for local testing. But sometimes you want to start container automatically.


    You might get an exception like this:


    Caused by: org.jboss.arquillian.spi.DeploymentException: Could not deploy test.war
        at org.jboss.arquillian.jbossas.local60.JBossASLocalContainer.deploy(
        at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(
        at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(
        ... 18 more
    Caused by: javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost/ [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost/ [Root exception is Connection refused: connect]]]


    JBOSS_HOME and JAVA_HOME needs to be set, either as environment variables or arquillian.xml.


    I personally prefer setting JAVA_HOME by environment variable and jbossHome by specific arquillian.xml.


    example src/test/resources/arquillian.xml:



    <?xml version="1.0"?>


    <arquillian xmlns=""


            <!-- <javaHome>/usr/lib/jvm/java-6-openjdk</javaHome> Will default o JAVA_HOME-->
            <httpPort>8080</httpPort> <!-- WARN: this is not the bind port, but connect port. Bind port must be set in jboss xml config -->





    So from now, Arquillian will startup server, if no JBossAS is running already.