Version 3

    A protocol is how Arquillian communicates with the container to execute the tests remotely (i.e., in-container). For ease of development and configuration, a container defines a default protocol that will be used if no other is specified.

     

    The container adapter for JBoss AS 7 uses the JMX protocol by default rather than the more typical Servlet protocol. As a result, the web contexts required by scoped CDI beans do not get activated when the test is run. You may encounter other problems that can be traced back to the use of the JMX protocol as well.

     

    The solution is to force the JBoss AS 7 container adapter to use the Servlet protocol. The protocol can be set inside a container configuration element in arquillian.xml: (SKIP THIS OPTION, NOT CURRENTLY WORKING. See ARQ-579)

     

    <arquillian xmlns="http://jboss.org/schema/arquillian"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
            http://jboss.org/schema/arquillian
            http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
    
        <container qualifier="jbossas-managed-7" default="true">
            <protocol type="Servlet 3.0"/>
        </container>
    
    </arquillian>
    

     

    Alternatively, you can set the protocol globally for all container adapters:

     

    <arquillian xmlns="http://jboss.org/schema/arquillian"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
            http://jboss.org/schema/arquillian
            http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
    
        <defaultProtocol type="Servlet 3.0"/>
    
    </arquillian>
    

     

    Note, however, that not all container adapters support the Servlet 3.0 protocol, such as Weld Embedded. If you make this the default protocol, you'll need to override this setting for containers adapters that don't support it. Otherwise, you'll get errors when you try to run tests using those container adapters.

     

    You can also set the protocol on the deployment method in the test itself:

     

    @Deployment @OverProtocol("Servlet 3.0")
    public static Archive<?> createDeployment() {
        return ShrinkWrap.create(JavaArchive.class)...
    }
    

     

    Finally, you need to add the Servlet protocol library to the Maven profile for the JBoss AS 7 container adapter.

     

    <dependency>
        <groupId>org.jboss.arquillian.protocol</groupId>
        <artifactId>arquillian-protocol-servlet</artifactId>
        <scope>test</scope>
    </dependency>
    

     

    Now your tests should be deployed to JBoss AS 7 using the Servlet 3.0 protocol instead of the JMX protocol.