Remote Arquillian test on Wildfly 10 inside docker fails with strange message: Got 403 (Forbidden)
axelberle Jul 19, 2016 3:16 PMI am trying to execute our arquillian tests on a remote wildfly-10 instance.
It works fine when I excute it on the same machine, but when inside a docker instance, it fails with a strange message.
Error launching test at http://127.0.0.1:8080/simple-test/ArquillianServletRunner?outputMode=serializedObject&className= .... Got 403 (Forbidden)
2016-07-19 17:54:13,667 main INFO Log4j appears to be running in a Servlet environment, but there's no log4j-web module available. If you want better web container support, please add the log4j-web JAR to your web archive or server lib directory.
2016-07-19 17:54:13,995 DEBUG [SimpleArquillianTest] Deployable test war: simple-test.war:
/WEB-INF/
/WEB-INF/classes/
/WEB-INF/classes/br/
/WEB-INF/classes/br/com/
/WEB-INF/classes/br/com/ml/
/WEB-INF/classes/br/com/ml/backend/
/WEB-INF/classes/br/com/ml/backend/services/
/WEB-INF/classes/br/com/ml/backend/services/pedido/
/WEB-INF/classes/br/com/ml/backend/services/pedido/PedidoDTO.class
/WEB-INF/classes/br/com/ml/backend/services/pedido/ItemDTO.class
/WEB-INF/classes/log4j.xml
/WEB-INF/beans.xml
XNIO version 3.3.4.Final
XNIO NIO Implementation Version 3.3.4.Final
JBoss Remoting version 4.0.18.Final
java.lang.IllegalStateException: Error launching test at http://127.0.0.1:8080/simple-test/ArquillianServletRunner?outputMode=serializedObject&className=tdd.br.com.ml.backend.services.log.SimpleArquillianTest&methodName=deveria_injectar_pedido&cmd=event. Got 403 (Forbidden)
at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.execute(ServletMethodExecutor.java:219)
at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor$1.run(ServletMethodExecutor.java:250)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.501 sec <<< FAILURE! - in tdd.br.com.ml.backend.services.log.SimpleArquillianTest
deveria_injectar_pedido(tdd.br.com.ml.backend.services.log.SimpleArquillianTest) Time elapsed: 0.047 sec <<< ERROR!
java.lang.IllegalStateException: Error launching test tdd.br.com.ml.backend.services.log.SimpleArquillianTest public void tdd.br.com.ml.backend.services.log.SimpleArquillianTest.deveria_injectar_pedido()
Caused by: java.lang.IllegalStateException: Error launching test at http://127.0.0.1:8080/simple-test/ArquillianServletRunner?outputMode=serializedObject&className=tdd.br.com.ml.backend.services.log.SimpleArquillianTest&methodName=deveria_injectar_pedido. Got 403 (Forbidden)
The test gets deployed in the Wildfly instance on docker, as can be seen in the log file generated:
2016-07-19 17:43:12,684 DEBUG [org.jboss.as.config] (MSC service thread 1-1) VM Arguments: -D[Standalone] -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/opt/jboss/wildfly/standalone/log/server.log -Dlogging.configuration=file:/opt/jboss/wildfly/standalone/configuration/logging.properties
2016-07-19 17:43:13,991 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
2016-07-19 17:43:14,012 INFO [org.xnio] (MSC service thread 1-4) XNIO version 3.3.4.Final
2016-07-19 17:43:14,023 INFO [org.xnio.nio] (MSC service thread 1-4) XNIO NIO Implementation Version 3.3.4.Final
2016-07-19 17:43:14,083 INFO [org.jboss.remoting] (MSC service thread 1-3) JBoss Remoting version 4.0.18.Final
2016-07-19 17:43:14,123 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.hsqldb.jdbcDriver (version 2.3)
2016-07-19 17:43:14,130 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 4 core threads with 32 task threads based on your 2 available processors
2016-07-19 17:43:14,135 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem.
2016-07-19 17:43:14,187 INFO [org.jboss.as.connector] (MSC service thread 1-1) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.2.Final)
2016-07-19 17:43:14,194 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0018: Started Driver service with driver-name = hsqldb
2016-07-19 17:43:14,216 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main]
2016-07-19 17:43:14,243 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem
2016-07-19 17:43:14,324 INFO [org.jboss.as.naming] (MSC service thread 1-1) WFLYNAM0003: Starting Naming Service
2016-07-19 17:43:14,332 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
2016-07-19 17:43:14,334 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
2016-07-19 17:43:14,355 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension
2016-07-19 17:43:14,363 INFO [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem
2016-07-19 17:43:14,380 INFO [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=4.9.4.Final
2016-07-19 17:43:14,413 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0003: Undertow 1.3.15.Final starting
2016-07-19 17:43:14,413 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0003: Undertow 1.3.15.Final starting
2016-07-19 17:43:14,552 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path '/opt/jboss/wildfly/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
2016-07-19 17:43:14,583 INFO [org.jboss.as.ejb3] (MSC service thread 1-1) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 8 (per class), which is derived from the number of CPUs on this host.
2016-07-19 17:43:14,584 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0012: Started server default-server.
2016-07-19 17:43:14,584 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0018: Host default-host starting
2016-07-19 17:43:14,583 INFO [org.jboss.as.ejb3] (MSC service thread 1-3) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 32 (per class), which is derived from thread worker pool sizing.
2016-07-19 17:43:14,691 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTP listener default listening on 0.0.0.0:8080
2016-07-19 17:43:14,982 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) WFLYDS0013: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
2016-07-19 17:43:15,115 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-3) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
2016-07-19 17:43:15,124 INFO [org.jboss.ws.common.management] (MSC service thread 1-4) JBWS022052: Starting JBossWS 5.1.3.Final (Apache CXF 3.1.4)
2016-07-19 17:43:15,223 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) WFLYJCA0001: Bound data source [java:jboss/jdbc/carf_test_integration]
2016-07-19 17:43:15,575 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://0.0.0.0:9990/management
2016-07-19 17:43:15,580 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://0.0.0.0:9990
2016-07-19 17:43:15,581 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.0.0.Final (WildFly Core 2.0.10.Final) started in 3552ms - Started 267 of 553 services (371 services are lazy, passive or on-demand)
2016-07-19 17:43:50,179 INFO [org.jboss.as.repository] (management-handler-thread - 1) WFLYDR0001: Content added at location /opt/jboss/wildfly/standalone/data/content/39/9ad3f064785073f6c396fffb7cea4bc7314527/content
2016-07-19 17:43:50,201 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0027: Starting deployment of "simple-test.war" (runtime-name: "simple-test.war")
2016-07-19 17:43:50,690 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0003: Processing weld deployment simple-test.war
2016-07-19 17:43:50,738 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-4) HV000001: Hibernate Validator 5.2.3.Final
2016-07-19 17:43:50,949 INFO [org.jboss.weld.deployer] (MSC service thread 1-3) WFLYWELD0006: Starting Services for CDI deployment: simple-test.war
2016-07-19 17:43:50,976 INFO [org.jboss.weld.Version] (MSC service thread 1-3) WELD-000900: 2.3.2 (Final)
2016-07-19 17:43:51,018 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0009: Starting weld service for deployment simple-test.war
2016-07-19 17:43:51,888 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 64) WFLYUT0021: Registered web context: /simple-test
2016-07-19 17:43:51,940 INFO [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0010: Deployed "simple-test.war" (runtime-name : "simple-test.war")
2016-07-19 17:43:52,325 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 64) WFLYUT0022: Unregistered web context: /simple-test
2016-07-19 17:43:52,358 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0010: Stopping weld service for deployment simple-test.war
2016-07-19 17:43:52,399 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0028: Stopped deployment simple-test.war (runtime-name: simple-test.war) in 80ms
2016-07-19 17:43:52,418 INFO [org.jboss.as.repository] (management-handler-thread - 2) WFLYDR0002: Content removed from location /opt/jboss/wildfly/standalone/data/content/39/9ad3f064785073f6c396fffb7cea4bc7314527/content
2016-07-19 17:43:52,418 INFO [org.jboss.as.server] (management-handler-thread - 2) WFLYSRV0009: Undeployed "simple-test.war" (runtime-name: "simple-test.war")
The (relevant parts of) standalone2.xml are: (belive me, I tired all kinds of combinations, fixed IPs and all):
<?xml version='1.0' encoding='UTF-8'?> <server xmlns="urn:jboss:domain:4.0"> ... <interfaces> <interface name="management"> <inet-address value="${jboss.bind.address.management}"/> </interface> <interface name="public"> <any-address/> </interface> </interfaces> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"> <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/> <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/> <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/> <socket-binding name="http" port="${jboss.http.port:8080}"/> <socket-binding name="https" port="${jboss.https.port:8443}"/> <socket-binding name="txn-recovery-environment" port="4712"/> <socket-binding name="txn-status-manager" port="4713"/> <outbound-socket-binding name="mail-smtp"> <remote-destination host="localhost" port="25"/> </outbound-socket-binding> </socket-binding-group> </server>
This is the docker file used for the wildlfy image: (awberle/wildfly-10-carf)
FROM jboss/base-jdk:8 MAINTAINER "axelberle@yahoo.de" # Set the WILDFLY_VERSION env variable ENV WILDFLY_VERSION 10.0.0.Final ENV JBOSS_HOME /opt/jboss/wildfly # Add the WildFly distribution to /opt, and make wildfly the owner of the extracted tar content # Make sure the distribution is available from a well-known place RUN cd $HOME \ && curl -O https://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz \ && tar xf wildfly-$WILDFLY_VERSION.tar.gz \ && mv $HOME/wildfly-$WILDFLY_VERSION $JBOSS_HOME \ && rm wildfly-$WILDFLY_VERSION.tar.gz # Ensure signals are forwarded to the JVM process correctly for graceful shutdown ENV LAUNCH_JBOSS_IN_BACKGROUND true ENV MODULE_PATH /modules/system/layers/base/ ENV POSTGRESQL_DRIVER postgresql-9.4.1208.jar ENV HSQLDB_DRIVER hsqldb-2.3.3.jar ENV POSTGRESQL_FILE ${MODULE_PATH}/org/postgresql/main/${POSTGRESQL_DRIVER} ENV POSTGRESQL_MODULE ${MODULE_PATH}/org/postgresql/main/module.xml ENV HSQLDB_FILE ${MODULE_PATH}/org/hsqldb/main/${HSQLDB_DRIVER} ENV HSQLDB_MODULE ${MODULE_PATH}/org/hsqldb/main/module.xml # Copy drivers ADD ${POSTGRESQL_FILE} ${JBOSS_HOME}/${POSTGRESQL_FILE} ADD ${POSTGRESQL_MODULE} ${JBOSS_HOME}/${POSTGRESQL_MODULE} ADD ${HSQLDB_FILE} ${JBOSS_HOME}/${HSQLDB_FILE} ADD ${HSQLDB_MODULE} ${JBOSS_HOME}/${HSQLDB_MODULE} # Create admin user RUN $JBOSS_HOME/bin/add-user.sh admin 1admin1 --silent # Create report directory RUN mkdir $JBOSS_HOME/standalone/test-reports # Expose the ports we're interested in EXPOSE 8080 EXPOSE 9990 # Set the default command to run on boot # This will boot WildFly in the standalone mode and bind to all interface ENTRYPOINT ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0", "--server-config=config/standalone2.xml"]
I start the wildfly docker instance like this:
sudo docker run -d -it --name wildfly-carf10-tests -p 8080:8080 -p 9992:9990 \ -v /app/mlcarf_arquillian_integration_tests/wildfly-config:/opt/jboss/wildfly/standalone/configuration/config \ -v /app/mlcarf_arquillian_integration_tests/logs/:/opt/jboss/wildfly/standalone/log/ \ -v /app/mlcarf_arquillian_integration_tests/test-reports/:/opt/jboss/wildfly/standalone/test-reports/ \ awberle/wildfly-10-carf:1.1
Arquillian.xml is configures like this: (I also tried a fixed IP here)
<?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"> <engine> <property name="deploymentExportPath">target/deployments</property> </engine> <container qualifier="wildfly-remote" default="true"> <configuration> <property name="managementAddress">localhost</property> <property name="managementPort">9992</property> <property name="username">admin</property> <property name="password">1admin1</property> </configuration> </container> </arquillian>
My test is this:
package tdd.br.com.ml.backend.services.log; import javax.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import br.com.ml.backend.services.pedido.ItemDTO; import br.com.ml.backend.services.pedido.PedidoDTO; @RunWith(Arquillian.class) public class SimpleArquillianTest { private static final Logger LOG = LoggerFactory.getLogger(SimpleArquillianTest.class); static final String WEB_CONTEXT = "simple-test"; @Deployment public static WebArchive createArchiveAndDeploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, WEB_CONTEXT + ".war"); war.addClass(PedidoDTO.class); war.addClass(ItemDTO.class); war.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); war.addAsResource("log4j.xml"); LOG.debug("Deployable test war: {} ", war.toString(true)); return war; } @Inject PedidoDTO pedidoDTO; @Test public void deveria_injectar_pedido() { LOG.debug("aqui"); Assert.assertNotNull(pedidoDTO); } }
My pom.ml is: (first the parent part, then the dependent module)
<dependencyManagement> <dependencies> <dependency> <groupId>org.jboss.spec</groupId> <artifactId>jboss-javaee-7.0</artifactId> <version>1.0.0.Final</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.18</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>org.jboss.arquillian</groupId> <artifactId>arquillian-bom</artifactId> <version>1.1.11.Final</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <dependency> <groupId>org.wildfly.arquillian</groupId> <artifactId>wildfly-arquillian-container-remote</artifactId> <version>2.0.0.Final</version> </dependency> </dependencies> </dependencyManagement> ... <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>br.com.ml</groupId> <artifactId>carf-parent</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> <artifactId>carf-backend</artifactId> <packaging>jar</packaging> <dependencies> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20160212</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.4</version> </dependency> <!-- Logging --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> </dependency> <!-- JEE --> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>7.0</version> <scope>provided</scope> </dependency> <!-- Jax-RS --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.7.3</version> <scope>provided</scope> </dependency> <!-- Hibernate framework --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>${hibernate.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.1-api</artifactId> <scope>provided</scope> </dependency> <!-- Test --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>2.3.3</version> <scope>test</scope> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.6.2</version> <scope>test</scope> </dependency> <!-- Arquillian --> <dependency> <groupId>org.jboss.arquillian.junit</groupId> <artifactId>arquillian-junit-container</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.jboss.shrinkwrap.resolver</groupId> <artifactId>shrinkwrap-resolver-depchain</artifactId> <type>pom</type> <scope>test</scope> </dependency> <!-- BDD --> <!-- this version comes from the cukespace fork, hosted on my github account --> <dependency> <groupId>com.github.cukespace</groupId> <artifactId>cukespace-core</artifactId> <version>1.6.2_1</version> <scope>test</scope> </dependency> <dependency> <groupId>net.masterthought</groupId> <artifactId>cucumber-reporting</artifactId> <version>2.2.0</version> <scope>test</scope> </dependency> </dependencies> <build> <testResources> <testResource> <filtering>true</filtering> <directory>${project.basedir}/src/test/resources</directory> </testResource> <testResource> <filtering>true</filtering> <directory>${project.basedir}/src/test/java</directory> </testResource> </testResources> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <executions> <execution> <phase>initialize</phase> <goals> <goal>read-project-properties</goal> </goals> <configuration> <files> <file>${project.parent.basedir}/config.properties</file> </files> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> </plugin> </plugins> </build> <profiles> <profile> <id>wildfly-remote</id> <activation> <activeByDefault>true</activeByDefault> </activation> <dependencies> <!-- Arquillian WildFly Remote Container Adapter --> <dependency> <groupId>org.wildfly.arquillian</groupId> <artifactId>wildfly-arquillian-container-remote</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> <configuration> <systemPropertyVariables> <arquillian.launch>wildfly-remote</arquillian.launch> </systemPropertyVariables> </configuration> </plugin> </plugins> </build> </profile> </profiles> </project> </profile>
Any help would be very appreciated!