Saturday, May 16, 2015

Now I have Tomcat with Arquillian

Beginning mid of April until now, I have already spent almost 27 hours on the alien tool, Arquillian. The major problem I'm facing with this tool is the setup, the setup guide didn't mention clearly which Arquillian version should correlated with JBoss version. End up I spent my whole day fighting on the version issue. As of today, I am still failing to make it work with JBoss. This has greatly jeopardize my progress.

This is what make me failed during the setup for JBoss.
        <dependency>
         <groupid>org.jboss.spec</groupid>
         <artifactid>jboss-javaee-6.0</artifactid>
         <version>3.0.2.Final</version>
         <type>pom</type>
         <scope>provided</scope>
        </dependency>
        <dependency>
         <groupid>org.jboss.as</groupid>
         <artifactid>jboss-as-arquillian-container-managed</artifactid>
         <scope>test</scope>
        </dependency>
And this is what I have for Arquillian:
        <dependency>
            <groupid>org.jboss.arquillian.junit</groupid>
            <artifactid>arquillian-junit-container</artifactid>
            <scope>test</scope>
        <dependency>
            <groupid>org.jboss.arquillian.protocol</groupid>
            <artifactid>arquillian-protocol-servlet</artifactid>
            <scope>test</scope>
        </dependency>
        <dependency>
         <groupid>org.jboss.arquillian.graphene</groupid>
         <artifactid>graphene-webdriver-drone</artifactid>
         <version>2.0.0.Alpha3</version>
         <scope>test</scope>
        </dependency>
        <dependency>
         <groupid>org.jboss.arquillian.extension</groupid>
         <artifactid>arquillian-drone-webdriver</artifactid>
         <scope>test</scope>
        </dependency>
        <dependency>
         <groupid>org.jboss.arquillian.extension</groupid>
         <artifactid>arquillian-drone-webdriver-depchain</artifactid>
         <type>pom</type>
         <scope>test</scope>
        </dependency>
So far I only manage to make it work on Tomcat, and this is what I have for Tomcat:
        <dependency>
         <groupId>org.jboss.arquillian.container</groupId>
         <artifactId>arquillian-tomcat-embedded-7</artifactId>
         <version>1.0.0.CR4</version>
         <scope>test</scope>
        </dependency>
        <dependency>
         <groupId>org.apache.tomcat.embed</groupId>
         <artifactId>tomcat-embed-core</artifactId>
         <version>7.0.42</version>
         <scope>test</scope>
        </dependency>
        <dependency>
         <groupId>org.apache.tomcat.embed</groupId>
         <artifactId>tomcat-embed-jasper</artifactId>
         <version>7.0.42</version>
         <scope>test</scope>
        </dependency>
        <dependency>
         <groupId>org.apache.tomcat.embed</groupId>
         <artifactId>tomcat-embed-logging-juli</artifactId>
         <version>7.0.42</version>
         <scope>test</scope>
        </dependency>
        <dependency>
         <groupId>org.eclipse.jdt.core.compiler</groupId>
         <artifactId>ecj</artifactId>
         <version>4.2.2</version>
         <scope>test</scope>
        </dependency>
When running on Tomcat, there is additional stuff is needed which is not mentioned in Arquillian documentation, but I found it in the forum mention that I must have org.jboss.weld.environment.servlet.Listener in web.xml. First the following library is require:
        <dependency>
         <groupId>org.jboss.weld.servlet</groupId>
         <artifactId>weld-servlet</artifactId>
         <version>2.0.3.Final</version>
         <scope>test</scope>
        </dependency>
And then create a new web.xml in src/test/resources with following content:
<web-app id="WebApp_ID" version="3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
 <display-name>WebEngineering3</display-name>
 <welcome-file-list>
  <welcome-file>index.xhtml</welcome-file>
 </welcome-file-list>
 
 <servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
 </servlet-mapping>
 
 <listener>
  <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
 </listener>
</web-app>

No comments: