Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-1217

EAP quickstart helloworld-html5: JAX-RS Application class gets generated even though JAX-RS is set up in web.xml

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 2017.5.0
    • Component/s: None
    • Labels:
      None
    • Sprint:
      2017-Apr-A, 2017-Apr-B

      Description

      I'm trying to run the Arquillian tests in the EAP quickstart helloworld-html5, like this:

      1. git clone -b 7.0.x https://github.com/jboss-developer/jboss-eap-quickstarts.git
      2. cd jboss-eap-quickstarts/helloworld-html5
      3. mvn clean package
      4. cd functional-tests
      5. change version.jboss.bom.eap in pom.xml to 7.0.0.GA
      6. add an exclusion to the dependency on org.jboss.arquillian.graphene:graphene-webdriver:
        <dependency>
            <groupId>org.jboss.arquillian.graphene</groupId>
            <artifactId>graphene-webdriver</artifactId>
            <scope>test</scope>
            <type>pom</type>
            <exclusions>
                <exclusion>
                    <groupId>asm</groupId>
                    <artifactId>asm</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
      7. change pom.xml to include this profile:
        <profile>
            <id>arq-wildfly-swarm</id>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly.swarm</groupId>
                    <artifactId>arquillian</artifactId>
                    <version>2017.3.3</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${version.surefire.plugin}</version>
                        <configuration>
                            <systemPropertyVariables>
                                <arquillian.xml>arquillian-swarm.xml</arquillian.xml>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        
      8. add src/test/resources/arquillian-swarm.xml file with this content:
        <?xml version="1.0" encoding="UTF-8"?>
        <arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian" xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
            <container qualifier="wildfly-swarm" default="true">
                <configuration>
                    <property name="host">localhost</property>
                    <property name="port">${swarm.arquillian.daemon.port:12345}</property>
                </configuration>
            </container>
            
            <extension qualifier="webdriver">
                <property name="browser">firefox</property>
            </extension>
        </arquillian>
        
      9. LC_ALL=C PATH=/home/lthon/tmp/firefox-45.8.0-esr/:$PATH mvn clean test -Parq-wildfly-swarm # note that Firefox 45 ESR is required because of Selenium deficiency.

      Both tests fail because they can't find the expected elements on the page. After a bit of investigation, I found that this is because Swarm auto-generates a JAX-RS Application class even though JAX-RS is set up in web.xml:

          <!-- One of the ways of activating REST Services is adding these lines.
               The server is responsible for adding the corresponding servlet automatically.
               The class org.jboss.as.quickstarts.html5rest.HelloWorld class has the
               annotation @Path("/") to receive the REST invocation -->
          <servlet-mapping>
              <servlet-name>javax.ws.rs.core.Application</servlet-name>
              <url-pattern>/hello/*</url-pattern>
          </servlet-mapping>
      

      I had no idea it's enough to specify a <servlet-mapping> without a <servlet> and especially a <servlet-class> but apparently it works. And if I comment out the call to addGeneratedApplication() in the constructor of JAXRSArchiveImpl and try to run the tests with this rebuilt Swarm, both tests pass just fine, like with WildFly proper.

      I believe that the check for hasApplicationPathAnnotation in JAXRSArchiveImpl.addGeneratedApplication is insufficient and should take web.xml into account. Not sure exactly how... Or at least a system property / configurable for switching off the automagic JAX-RS Application class generation.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mkouba Martin Kouba
                Reporter:
                lthon Ladislav Thon
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: