1 Reply Latest reply: May 1, 2012 6:15 PM by Dan Allen RSS

Results from testing TomEE container adapters

Dan Allen Master

Upon the release of TomEE 1.0.0, I decide to give the bundled Arquillian container adapters a go.

 

I began with the project created in the Arquillian Getting Started guide, then added the TomEE container adapters. My first goal was to see if they would run the basic CDI test. If that worked, my plan was to continue going through the other guides.

 

Goal #1: Execute the GreeterTest on TomEE embedded and remote

 

Add the Maven profiles for TomEE (embedded, managed and remote) to pom.xml:

 

<profile>
    <id>arquillian-tomee-embedded</id>
    <dependencies>
        <dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>arquillian-tomee-embedded</artifactId>
            <version>1.0.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</profile>
<profile>
    <id>arquillian-tomee-managed</id>
    <dependencies>
        <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.apache.openejb</groupId>
            <artifactId>arquillian-tomee-managed</artifactId>
            <version>1.0.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</profile>
<profile>
    <id>arquillian-tomee-remote</id>
    <dependencies>
        <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.apache.openejb</groupId>
            <artifactId>arquillian-tomee-remote</artifactId>
            <version>1.0.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</profile>

 

Run the test with TomEE embedded:

 

Passed: yes

 

Run the test with TomEE remote:

 

Passed: no

Exception:

http://pastie.org/3845636

 

Goal #2: Execute the GreeterTest on Tomcat 7 managed and remote

 

After giving it some thought, I realized that if TomEE is launched just like Tomcat, then the Tomcat 7 adapters should work just fine. So I turned to giving those adapters a try:

 

Maven profile:

 

<profile>
    <id>arquillian-tomcat-managed</id>
    <dependencies>
        <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.arquillian.container</groupId>
            <artifactId>arquillian-tomcat-managed-7</artifactId>
            <version>1.0.0.CR3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</profile>

 

arquillian.xml container configuration:

 

<container qualifier="tomcat-managed-7" default="true">
    <configuration>
        <property name="catalinaHome">${user.home}/opt/apache-tomee-web-1.0.0</property>
        <property name="user">manager</property>
        <property name="pass">manager</property>
    </configuration>
</container>

 

TomEE configuration tomcat-users.xml

 

<tomcat-users>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <user username="manager" password="manager" roles="manager-gui,manager-script"/>
</tomcat-users>

 

Passed: yes (with exceptions)

Exceptions in console:

http://pastie.org/3845784

 

The test does not work with the Tomcat 6 remote adapter for at least two reasons:

 

  • adapter requires a patch to work with Tomcat 7 (because the manager URLs changed). See ARQ-865
  • adapter uses Servlet 2.5 protocol, which creates an EAR file, which TomEE cannot deploy (or for some reason it just doesn't work)

 

Other problems encoutered:

 

There do appear to be issues with classes leaking down into TomEE embedded from the project dependencies. For instance, I added Seam Validation as a dependency (but not to the test) and it led to the following exception:

 

SEVERE: CDI Beans module deployment failed
javax.enterprise.inject.CreationException: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
          at org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:200)

 

This could be a result of a general problem with Seam Validation and OWB, or perhaps it is something else.

  • 1. Re: Results from testing TomEE container adapters
    Dan Allen Master

    I got the test to pass using Tomcat 6 remote adapter with these two fixes:

     

    • Patch the adapter to use the '/text' prefix for manager URLs
    • Set the default protocol to Servlet 3.0 in arquillian.xml:
      <defaultProtocol type="Servlet 3.0"/>
    • Set JAVA_OPTS as follows before starting TomEE*
      JAVA_OPTS="-Dcom.sun.management.jmxremote.port=8089 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

     

    * This seems to be a general requirement for getting the Tomcat remote adapter to work over the Servlet 3.0 protocol.