JAV
JAV

Reputation: 36

Trying to run an Arquillian Test for an ear and getting ArquillianServletRunner not found

I am trying to run a test using Arquillian for my ear. I create the deployment importing my existing ear and then I add a web archive module with my test.

@RunWith(Arquillian.class)
public class MyTest {
    @Deployment
    public static Archive createDeployment() {
        EnterpriseArchive ear = ShrinkWrap.createFromZipFile(EnterpriseArchive.class , new File("/location/to/my/ear") );
        WebArchive arc = Testable.archiveToTest( ShrinkWrap.create(WebArchive.class, "MyTest.war").addClass(MyTest.class).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") );
        return ear.addAsModule( arc );
    }
    ....
}

I am using JBoss EAP 6.3.0 as my container (managed)

<?xml version="1.0" encoding="UTF-8"?>
<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" />

    <container qualifier="jbossas-managed" default="true">
        <configuration>
        </configuration>
    </container>
</arquillian>

in my pom.xml

<dependencies>
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
    <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>7.2.0.Final</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.protocol</groupId>
        <artifactId>arquillian-protocol-servlet</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

When I run the test I get the following exception

java.lang.IllegalArgumentException: ArquillianServletRunner not found. Could not determine ContextRoot from ProtocolMetadata, please contact DeployableContainer developer. at org.jboss.arquillian.protocol.servlet.ServletUtil.determineBaseURI(ServletUtil.java:64) at org.jboss.arquillian.protocol.servlet.ServletURIHandler.locateTestServlet(ServletURIHandler.java:60)

I have verified that the deployed ear contains the MyTest.war module as well as the arquillian-related jars in the lib folder of the ear.

Any help is greatly appreciated.

Upvotes: 1

Views: 1731

Answers (1)

Guillermo
Guillermo

Reputation: 1533

When it is configured to use servlet 3.0 protocol Arquillian define the servlet ArquillianServletRunner in the web.xml or web-fragment.xml and includes the arquillian-protocol.jar into a test.war that its added as module of the ear returned by the createDeployment function in your case.

Maybe you coud include that arquillian's library and define the servlet into the web.xml of the MyTest.war. The web-fragment.xml looks like this, take the servlet definition from it.

You can also add the engine/deploymentExportPath into the arquillian.xml to save the final archive deployed by arquillian. See more here in the section Export the Deployment.

PD: someone says that the absent of the servlet's definition occurs when you add a webInfResource entry but I didn't probe it.

Upvotes: 1

Related Questions