Yearly Archives: 2014

WildFly/JavaEE7 and MySQL linked on two Docker containers (Tech Tip #66)

Tech Tip #61 showed how to run Java EE 7 hands-on lab on WildFly Docker container. A couple of assumptions were made in that case:

  • WildFly bundles H2 in-memory database. The Java EE 7 application uses the default database resource, which in case of WildFly, gets resolved to a JDBC connection to that in-memory database. This is a good way to start building your application but pretty soon you want to start using a real database, like MySQL.
  • Typically, Application Server and Database may not be residing on the same host. This reduces the risk by avoiding a single point of failure. And so WildFly and MySQL would be on to separate host.

There is plethora of material available to show how to configure WildFly and MySQL on separate hosts. What are the design patterns, and anti-patterns, if you were to do that using Docker?

Lets take a look!

In simplified steps:

  1. Run the MySQL container as:
    docker run --name mysqldb -e MYSQL_USER=mysql -e MYSQL_PASSWORD=mysql -e MYSQL_DATABASE=sample -e MYSQL_ROOT_PASSWORD=supersecret -d mysql
  2. Run the WildFly container, with MySQL JDBC resource pre-configured, as:
    docker run --name mywildfly --link mysqldb:db -p 8080:8080 -d arungupta/wildfly-mysql-javaee7
  3. Find the IP address of the WildFly container:
    sudo docker inspect -f '{{ .NetworkSettings.IPAddress }}' mywildfly

    If you are on a Mac, then use boot2docker ip to find the IP address.

  4. Access the application as:
    curl http://<IP_ADDRESS>:8080/employees/index.html

    to see the output as:

    <!DOCTYPE html>
    <html>
        <head>
            <title>Employees</title>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
        </head>
        <body>
            <ul>
                <li>GET <a href="resources/employees">all</a> employees.</li>
                <li>GET <a href="resources/employees/1">1</a> employee.</li>
            </ul>
        </body>
    </html>

    The application is a trivial Java EE 7 application that publishes a REST endpoint. Access it as:

    curl http://localhost:8080/employees/resources/employees/

    to see:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><collection><employee><id>1</id><name>Penny</name></employee><employee><id>2</id><name>Sheldon</name></employee><employee><id>3</id><name>Amy</name></employee><employee><id>4</id><name>Leonard</name></employee><employee><id>5</id><name>Bernadette</name></employee><employee><id>6</id><name>Raj</name></employee><employee><id>7</id><name>Howard</name></employee><employee><id>8</id><name>Priya</name></employee></collection>

If you are interested in nitty gritty, read further details.

Linking Containers

The first concept we need to understand is how Docker allows linking containers. Creating a link between two containers creates a conduit between a source container and a target container and securely transfer information about source container to target container. In our case, target container (WildFly) can see information about source container (MySQL). The important part to understand here is that none of this information needs to be publicly exposed by the source container, and is only made available to the target container.

The magic switch to enable link is, intuitively, --link. So for example, if MySQL and WildFly containers are run as shown above, then --link mysqldb:db links the MySQL container named mysqldb with an alias db to the WildFly target container. This defines some environment variables, following the defined protocol, in the target container which can then be used to access information about the source container. For example, IP address, exposed ports, username, passwords, etc. The complete list of environment variables can be seen as:

[arun@localhost wildfly-mysql-javaee7]$ sudo docker run --name mywildfly --link mysqldb:db -p 8080:8080 -it arungupta/wildfly-mysql-javaee7 env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=4e0458981a82
TERM=xterm
DB_PORT=tcp://172.17.0.24:3306
DB_PORT_3306_TCP=tcp://172.17.0.24:3306
DB_PORT_3306_TCP_ADDR=172.17.0.24
DB_PORT_3306_TCP_PORT=3306
DB_PORT_3306_TCP_PROTO=tcp
DB_NAME=/mywildfly3/db
DB_ENV_MYSQL_USER=mysql
DB_ENV_MYSQL_PASSWORD=mysql
DB_ENV_MYSQL_DATABASE=sample
DB_ENV_MYSQL_ROOT_PASSWORD=supersecret
DB_ENV_MYSQL_MAJOR=5.6
DB_ENV_MYSQL_VERSION=5.6.22
JAVA_HOME=/usr/lib/jvm/java
WILDFLY_VERSION=8.2.0.Final
JBOSS_HOME=/opt/jboss/wildfly
HOME=/opt/jboss

So you can see there are DB_* environment variables providing plenty of information about source container.

Linking only works if all the containers are running on the same host. A better solution will be shown in the subsequent blog, stay tuned.

Override default Docker command

Dockerfile for this image inherits from jboss/wildfly:latest and starts the WildFly container. Docker containers can only run one command but we need to install JDBC driver, create JDBC resource using the correct IP address and port, and deploy the WAR file. So we will override the command by inheriting from jboss/wildfly:latest and use a custom command. This command will do everything that we want to do, and then start WildFly as well.

The custom command does the following:

  • Add MySQL module
  • Add MySQL JDBC driver
  • Add the JDBC data source using IP address and port of the linked MySQL container
  • Deploy the WAR file
  • Start WildFly container

Note, WildFly is starting with -b 0.0.0.0 that allows it to be bound to any IP address. Also, the command needs to run in foreground so that the container stays active.

Customizing security

Ideally, you’ll poke holes in the firewall to enable connection to specific host/ports. But these instructions were tried on Fedora 20 running in Virtual Box. So for convenience, the complete firewall was disabled as:

sudo systemctl stop firewall
sudo systemctl disable firewall

In addition, a Host-only adapter was added using Virtual Box settings and looks like:

techtip65-host-only-adapter

That’s it, that should get you going to to use WildFly and MySQL on two separate containers.

Also verified the steps on boot2docker, and it worked seamlessly there too:

docker-images> docker run --name mysqldb -e MYSQL_USER=mysql -e MYSQL_PASSWORD=mysql -e MYSQL_DATABASE=sample -e MYSQL_ROOT_PASSWORD=supersecret -d mysql
docker-images> 
docker-images> docker run --name mywildfly --link mysqldb:db -p 8080:8080 -d arungupta/wildfly-mysql-javaee7
Unable to find image 'arungupta/wildfly-mysql-javaee7' locally
Pulling repository arungupta/wildfly-mysql-javaee7
791773b0e1de: Download complete 
511136ea3c5a: Download complete 
782cf93a8f16: Download complete 
7d3f07f8de5f: Download complete 
1ef0a50fe8b1: Download complete 
20a1abe1d9bf: Download complete 
cd5bb934bb67: Download complete 
379edb00ab07: Download complete 
4d37cbbfc67d: Download complete 
2ea8562cac7c: Download complete 
7759146eab1a: Download complete 
b17a20d6f5f8: Download complete 
e02bdb6c4ed5: Download complete 
72d585299bb5: Download complete 
90832e1f0bb9: Download complete 
2c3484b42034: Download complete 
38fad13dea25: Download complete 
656878d9a6c6: Download complete 
6510de96c354: Download complete 
0cc86be8ac93: Download complete 
cc4e21e8b0e7: Download complete 
Status: Downloaded newer image for arungupta/wildfly-mysql-javaee7:latest
8522df362e57f5b7a5324dba692559b971c7cfda4a687212c44b1118008a4c63
docker-images> curl http://192.168.59.103:8080/employees/index.html
<!DOCTYPE html>
<html>
    <head>
        <title>Employees</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <ul>
            <li>GET <a href="resources/employees">all</a> employees.</li>
            <li>GET <a href="resources/employees/1">1</a> employee.</li>
        </ul>
    </body>
</html>
docker-images> curl http://192.168.59.103:8080/employees/resources/employees/
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><collection><employee><id>1</id><name>Penny</name></employee><employee><id>2</id><name>Sheldon</name></employee><employee><id>3</id><name>Amy</name></employee><employee><id>4</id><name>Leonard</name></employee><employee><id>5</id><name>Bernadette</name></employee><employee><id>6</id><name>Raj</name></employee><employee><id>7</id><name>Howard</name></employee><employee><id>8</id><name>Priya</name></employee></collection>

Source code for the image is at github.com/arun-gupta/docker-images/tree/master/wildfly-mysql-javaee7.

Enjoy!

Resolve “dial unix /var/run/docker.sock” error with Docker (Tech Tip #65)

I’ve played around with Docker configuration on Mac using boot2docker (#62, #61, #60, #59, #58, #57) and starting to play with native support on Fedora 20. Boot2docker starts as a separate VM on Mac and everything is pre-configured. Booting a fresh Fedora VM and trying to run Docker commands there gives:

[arun@localhost ~]$ sudo docker info
2014/12/22 11:19:38 Get http:///var/run/docker.sock/v1.15/info: dial
unix /var/run/docker.sock: no such file or directory

Debugging revealed that Docker daemon was not running on this VM. It can be easily started as:

sudo systemctl start docker

And then enable it to start automatically with every restart of the VM as:

sudo systemctl enable docker

Simple, isn’t it?

Enjoy!

Java EE Workflows on OpenShift (Tech Tip #64)

This webinar shows how create a Java EE workflow on OpenShift using WildFly, JBoss Tools, Forge, Arquillian, and OpenShift. Specifically it talks about:

  • How a Java EE application can be easily developed using JBoss Developer Studio and deployed directly to OpenShift
  • Set up Test and Production instances on OpenShift
  • Enable Jenkins to provide Continuous Integration
  • Run the tests on Test and push the WAR to Production

More detailed blog entries are at:

And a lot more at blog.arungupta.me/tag/openshift/.

Enjoy!

Modular Java EE applications with OSGi (Hanginar #3)

This hanginar (#1, #2) with Paul Bakker (@pbakker) shows how to build modular Java EE applications.

Learn all about:

  • Why is it important to build modular Java EE applications?
  • How OSGi enables modular applications?
  • See bndtools plugin in action using Eclipse
  • Learn how to transform an existing Java EE application to be modular
  • How to take a modular application to production?
  • Learn about Amdatu – open source OSGi components that enable Java EE modular applications

Many thanks to Paul Bakker (@pbakker) and Luminis for all the great work on enabling modular Java EE applications and participating in this series! Most of the work shown in this webinar is also explained in an O’Reilly book: Building Modular Clouds Apps with OSGi (co-authored with @BertErtman).

A tentative list of speakers for upcoming hanginars is identified at github.com/javaee-samples/webinars. Each speaker is assigned an issue which allows you to ask questions. Feel free to file an issue for any other speaker that should be on the list.

The next hanginar will be advertised ahead of time so that any body can participate!

Patching Weld 3 in WildFly 8.2 – First Experimental RI of Java EE 8 (Tech Tip #63)

Java EE 8 is moving along and several new component JSRs have been filed. JSR 365 will define the specification for CDI 2.0. Red Hat has already started working on the implementation prototype in Weld 3 and Alpha3 was released recently.

The Java EE 8 compliant application server from Red Hat will be WildFly where all the different technologies will be implemented. In the meanwhile, how do you try out these early experimental releases?

Tech Tip #29 showed how to patch WildFly 8.x from a previous release. This tip will leverage that mechanism to install Weld 3 Alpha3 in WildFly 8.2. You can also download Weld 3 Alpha3 Standalone or Weld 3 Alpha3 as patch to WildFly 9.0 Alpha1.

The instructions are rather simple:

  1. Download and unzip WildFly 8.2:
    http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.zip
    unzip wildfly-8.2.0.Final.zip
    
  2. Download Weld 3 Alpha3 Patch for WildFly 8.2:
    curl -L -o weld3-alpha3-patch-wildfly8.2.zip http://sourceforge.net/projects/jboss/files/Weld/3.0.0.Alpha3/wildfly-8.2.0.Final-weld-3.0.0.Alpha3-patch.zip/download
  3. Apply the patch as (also available in README bundled in the patch):
    ./wildfly-8.2.0.Final/bin/jboss-cli.sh --command="patch apply ./weld3-alpha3-patch-wildfly8.2.zip"
    {
        "outcome" : "success",
        "result" : {}
    }
  4. Start WildFly:
    ./wildfly-8.2.0.Final/bin/standalone.sh
  5. Run a simple CDI test from javaee7-samples:
    mvn -f cdi/nobeans-xml/pom.xml test -Dwildfly-remote-arquillian

    and see output in the WildFly console as:

    20:53:30,434 INFO  [org.jboss.as.repository] (management-handler-thread - 1) JBAS014900: Content added at location /Users/arungupta/tools/weld3/wildfly-8.2.0.Final/standalone/data/content/4c/c6675b4f1fb33fe40dda3f94ac4979b3e2a4d0/content
    20:53:30,453 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "test.war" (runtime-name: "test.war")
    20:53:30,878 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016002: Processing weld deployment test.war
    20:53:30,953 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-5) HV000001: Hibernate Validator 5.1.3.Final
    20:53:31,131 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016005: Starting Services for CDI deployment: test.war
    20:53:31,163 INFO  [org.jboss.weld.Version] (MSC service thread 1-5) WELD-000900: 3.0.0 (Alpha3)
    20:53:31,195 INFO  [org.jboss.weld.deployer] (MSC service thread 1-9) JBAS016008: Starting weld service for deployment test.war
    20:53:32,141 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-15) JBAS017534: Registered web context: /test
    20:53:32,178 INFO  [org.jboss.as.server] (management-handler-thread - 1) JBAS018559: Deployed "test.war" (runtime-name : "test.war")
    20:53:33,454 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017535: Unregistered web context: /test
    20:53:33,464 INFO  [org.jboss.weld.deployer] (MSC service thread 1-16) JBAS016009: Stopping weld service for deployment test.war
    20:53:33,490 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-12) JBAS015877: Stopped deployment test.war (runtime-name: test.war) in 40ms
    20:53:33,497 INFO  [org.jboss.as.repository] (management-handler-thread - 1) JBAS014901: Content removed from location /Users/arungupta/tools/weld3/wildfly-8.2.0.Final/standalone/data/content/4c/c6675b4f1fb33fe40dda3f94ac4979b3e2a4d0/content
    20:53:33,498 INFO  [org.jboss.as.server] (management-handler-thread - 1) JBAS018558: Undeployed "test.war" (runtime-name: "test.war")

    Note that the Weld version of “3.0.0 (Alpha 3)” is shown appropriately in the logs.

In terms of features, here is what is available so far:

  • Declarative ordering of observer methods using @Priority
  • Ability for an extension to veto and modify an observer method
  • Support for Java 8 repeatable annotations as qualifiers and interceptor bindings
  • Enhanced AnnotatedType API
  • Asynchronous events
  • Simplified configuration of Weld-specific properties
  • Guava is no longer used internally

More details, including code samples, are explained in Weld 3.0.0 Alpha1 Released and An update on Weld 3. All the prototyped API is in org.jboss.weld.experimental package indicating the early nature.

Here are some resources for you to look at:

  • Javadocs
  • Maven coordinates
    <dependency>
        <groupId>org.jboss.weld</groupId>
        <artifactId>weld-api</artifactId>
        <version>3.0.Alpha3</version>
    </dependency>
  • Feedback at Weld forums or the cdi-dev mailing list.

Created Java EE 8 Samples repository and will start adding some CDI 2.0 samples there, stay tuned.

Enjoy!

Run Java EE Tests on Docker using Arquillian Cube (Tech Tip #62)

Tech Tip #61 showed how to run Java EE 7 Hands-on Lab using Docker. The Dockerfile used there can be used to create a new image that can deploy any Java EE 7 WAR file to the WildFly instance running in the container.

For example github.com/arun-gupta/docker-images/blob/master/javaee7-test/Dockerfile can be copied to the root directory of javaee7-samples and be used to deploy jaxrs-client.war file to the container. Of course, you first need to build the sample as:

mvn -f jaxrs/jaxrs-client/pom.xml clean package -DskipTests

The exact Dockerfile is shown here:

FROM arungupta/wildfly-centos
ADD jaxrs/jaxrs-client/target/jaxrs-client.war /opt/wildfly/standalone/deployments/

If you want to deploy another Java EE 7 application, then you need to do the following steps:

  • Create the WAR file of the sample
  • Change the Dockerfile
  • Build the image
  • Stop the previous container
  • Start the new container

Now, if you want to run tests against this instance then mvn test alone will not do it because either you need to bind the IP address of the Docker container statically, or dynamically find out the address and then patch it at runtime. Anyway, the repeated cycle is little too cumbersome. How do you solve it?

Meet Arquillian Cube!

Arquillian Cube allows you to control the lifecycle of Docker images as part of the test lifecyle, either automatically or manually.

The blog entry provide more details about getting started with Arquillian Cube, and this functionality has now been enabled in “docker” branch of javaee7-samples. Arquillian Cube Extension Alpha2 was recently released and is used to provide integration. Here are the key concepts:

  • A new “wildfly-docker-arquillian” profile is being introduced
  • The profile adds a dependency on:
    <dependency>
        <groupId>org.arquillian.cube</groupId>
        <artifactId>arquillian-cube-docker</artifactId>
        <version>1.0.0.Alpha2</version>
        <scope>test</scope>
    </dependency>
  • Uses Docker REST API to talk to the container. Complete API docs shows the sample payloads and explains the query parameters and status codes.
  • Uses WildFly remote adapter to talk to the application server running within the container
  • Configuration for Docker image is specified as part of maven-surefire-plugin.:
    <configuration>
        <systemPropertyVariables>
        <arquillian.launch>wildfly-docker</arquillian.launch>
        <arq.container.wildfly-docker.configuration.username>admin</arq.container.wildfly-docker.configuration.username>
        <arq.container.wildfly-docker.configuration.password>Admin#70365</arq.container.wildfly-docker.configuration.password>
        <arq.extension.docker.serverVersion>1.15</arq.extension.docker.serverVersion>
        <arq.extension.docker.serverUri>http://127.0.0.1:2375</arq.extension.docker.serverUri>
        <arq.extension.docker.dockerContainers>
            wildfly-docker:
                image: arungupta/javaee7-samples-wildfly
                exposedPorts: [8080/tcp, 9990/tcp]
                await:
                    strategy: polling
                    sleepPollingTime: 50000
                    iterations: 5
                portBindings: [8080/tcp, 9990/tcp]
        </arq.extension.docker.dockerContainers>
        </systemPropertyVariables>
    </configuration>

    Username and password are specified are for the WildFly in arungupta/javaee7-samples-wildfly image. All the configuration values can be overridden by arquillian.xml for each test case, as explained here.

How do you try out this functionality?

git clone https://github.com/javaee-samples/javaee7-samples.git
git checkout docker
mvn test -f servlet/simple-servlet/pom.xml -Pwildfly-docker-arquillian

Here is a complete log of running simple-servlet test:

Running org.javaee7.servlet.metadata.complete.SimpleServletTest
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Dec 04, 2014 11:19:51 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 1 * Sending client request on thread main
1 > GET http://127.0.0.1:2375/v1.15/_ping
 
Dec 04, 2014 11:19:51 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 2 * Client response received on thread main
2 < 200
2 < Content-Length: 2
2 < Content-Type: application/json; charset=utf-8
2 < Date: Thu, 04 Dec 2014 19:19:51 GMT
OK
 
Dec 04, 2014 11:19:51 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 3 * Sending client request on thread main
3 > POST http://127.0.0.1:2375/v1.15/containers/create?name=wildfly-docker
3 > Accept: application/json
3 > Content-Type: application/json
{"name":"wildfly-docker","Hostname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":null,"Cmd":null,"Dns":null,"Image":"arungupta/javaee7-samples-wildfly","Volumes":{},"VolumesFrom":[],"WorkingDir":"","DisableNetwork":false,"ExposedPorts":{"8080/tcp":{},"9990/tcp":{}}}
 
Dec 04, 2014 11:19:51 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 4 * Client response received on thread main
4 < 201
4 < Content-Length: 90
4 < Content-Type: application/json
4 < Date: Thu, 04 Dec 2014 19:19:51 GMT
{"Id":"d2fc85815256be7540ae85fef1ecb26a666a41a591e2adfae8aa6a32fde3393b","Warnings":null}
 
 
Dec 04, 2014 11:19:51 AM org.arquillian.cube.impl.docker.DockerClientExecutor assignPorts
INFO: Only exposed port is set and it will be used as port binding as well. 8080/tcp
Dec 04, 2014 11:19:51 AM org.arquillian.cube.impl.docker.DockerClientExecutor assignPorts
INFO: Only exposed port is set and it will be used as port binding as well. 9990/tcp
Dec 04, 2014 11:19:52 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 5 * Sending client request on thread main
5 > POST http://127.0.0.1:2375/v1.15/containers/wildfly-docker/start
5 > Accept: application/json
5 > Content-Type: application/json
{"containerId":"wildfly-docker","Binds":[],"Links":[],"LxcConf":null,"PortBindings":{"8080/tcp":[{"HostIp":"","HostPort":"8080"}],"9990/tcp":[{"HostIp":"","HostPort":"9990"}]},"PublishAllPorts":false,"Privileged":false,"Dns":null,"DnsSearch":null,"VolumesFrom":null,"NetworkMode":"bridge","Devices":null,"RestartPolicy":null,"CapAdd":null,"CapDrop":null}
 
Dec 04, 2014 11:19:52 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 6 * Client response received on thread main
6 < 204
6 < Date: Thu, 04 Dec 2014 19:19:52 GMT
 
Dec 04, 2014 11:19:52 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 7 * Sending client request on thread main
7 > GET http://127.0.0.1:2375/v1.15/containers/wildfly-docker/json
7 > Accept: application/json
 
Dec 04, 2014 11:19:52 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8 * Client response received on thread main
8 < 200
8 < Content-Type: application/json
8 < Date: Thu, 04 Dec 2014 19:19:52 GMT
8 < Transfer-Encoding: chunked
{"Args":["-b","0.0.0.0","-bmanagement","0.0.0.0"],"Config":{"AttachStderr":false,"AttachStdin":false,"AttachStdout":false,"Cmd":["/opt/wildfly/bin/standalone.sh","-b","0.0.0.0","-bmanagement","0.0.0.0"],"CpuShares":0,"Cpuset":"","Domainname":"","Entrypoint":null,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","WILDFLY_VERSION=8.1.0.Final","JBOSS_HOME=/opt/wildfly"],"ExposedPorts":{"8080/tcp":{},"9990/tcp":{}},"Hostname":"d2fc85815256","Image":"arungupta/javaee7-samples-wildfly","Memory":0,"MemorySwap":0,"NetworkDisabled":false,"OnBuild":null,"OpenStdin":false,"PortSpecs":null,"SecurityOpt":null,"StdinOnce":false,"Tty":false,"User":"wildfly","Volumes":null,"WorkingDir":""},"Created":"2014-12-04T19:19:51.7226858Z","Driver":"devicemapper","ExecDriver":"native-0.2","HostConfig":{"Binds":[],"CapAdd":null,"CapDrop":null,"ContainerIDFile":"","Devices":null,"Dns":null,"DnsSearch":null,"ExtraHosts":null,"Links":null,"LxcConf":null,"NetworkMode":"bridge","PortBindings":{"8080/tcp":[{"HostIp":"","HostPort":"8080"}],"9990/tcp":[{"HostIp":"","HostPort":"9990"}]},"Privileged":false,"PublishAllPorts":false,"RestartPolicy":{"MaximumRetryCount":0,"Name":""},"VolumesFrom":null},"HostnamePath":"/var/lib/docker/containers/d2fc85815256be7540ae85fef1ecb26a666a41a591e2adfae8aa6a32fde3393b/hostname","HostsPath":"/var/lib/docker/containers/d2fc85815256be7540ae85fef1ecb26a666a41a591e2adfae8aa6a32fde3393b/hosts","Id":"d2fc85815256be7540ae85fef1ecb26a666a41a591e2adfae8aa6a32fde3393b","Image":"3d08e8466496412daadeba7bb35b5b64d29b32adedd64472ad775d6da5011913","MountLabel":"system_u:object_r:svirt_sandbox_file_t:s0:c34,c113","Name":"/wildfly-docker","NetworkSettings":{"Bridge":"docker0","Gateway":"172.17.42.1","IPAddress":"172.17.0.7","IPPrefixLen":16,"MacAddress":"02:42:ac:11:00:07","PortMapping":null,"Ports":{"8080/tcp":[{"HostIp":"0.0.0.0","HostPort":"8080"}],"9990/tcp":[{"HostIp":"0.0.0.0","HostPort":"9990"}]}},"Path":"/opt/wildfly/bin/standalone.sh","ProcessLabel":"system_u:system_r:svirt_lxc_net_t:s0:c34,c113","ResolvConfPath":"/var/lib/docker/containers/d2fc85815256be7540ae85fef1ecb26a666a41a591e2adfae8aa6a32fde3393b/resolv.conf","State":{"ExitCode":0,"FinishedAt":"0001-01-01T00:00:00Z","Paused":false,"Pid":11406,"Restarting":false,"Running":true,"StartedAt":"2014-12-04T19:19:52.378418242Z"},"Volumes":{},"VolumesRW":{}}
 
 
Dec 04, 2014 11:20:44 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.0.Beta2
Dec 04, 2014 11:20:44 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.0.Beta2
Dec 04, 2014 11:20:44 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version (unknown)
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 65.635 sec - in org.javaee7.servlet.metadata.complete.SimpleServletTest
Dec 04, 2014 11:20:54 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 9 * Sending client request on thread main
9 > POST http://127.0.0.1:2375/v1.15/containers/wildfly-docker/stop?t=10
9 > Accept: application/json
9 > Content-Type: application/json
 
Dec 04, 2014 11:21:04 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 10 * Client response received on thread main
10 < 204
10 < Date: Thu, 04 Dec 2014 19:21:04 GMT
 
Dec 04, 2014 11:21:04 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 11 * Sending client request on thread main
11 > DELETE http://127.0.0.1:2375/v1.15/containers/wildfly-docker?v=0&force=0
11 > Accept: application/json
 
Dec 04, 2014 11:21:05 AM org.glassfish.jersey.filter.LoggingFilter log
INFO: 12 * Client response received on thread main
12 < 204
12 < Date: Thu, 04 Dec 2014 19:21:05 GMT
 
 
Results :
 
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
 
[INFO] 
[INFO] --- maven-surefire-plugin:2.17:test (spock-test) @ simple-servlet ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:27.831s
[INFO] Finished at: Thu Dec 04 11:21:05 PST 2014
[INFO] Final Memory: 21M/59M
[INFO] ------------------------------------------------------------------------

REST payload from the client to Docker server are shown here. This was verified on a Fedora 20 Virtual Box image. Here are some quick notes on setting it up there:

  1. Install the required packages
    yum install docker-io git maven
    yum upgrade selinux-policy
  2. Configure Docker
    sudo vi /etc/sysconfig/docker
    Change to "OPTIONS=--selinux-enabled -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock"
    sudo service docker start
  3. Verify Docker TCP configuration
    docker -H tcp://127.0.0.1:2375 version
    
    Client version: 1.3.1
    Client API version: 1.15
    Go version (client): go1.3.3
    Git commit (client): 4e9bbfa/1.3.1
    OS/Arch (client): linux/amd64
    Server version: 1.3.1
    Server API version: 1.15
    Go version (server): go1.3.3
    Git commit (server): 4e9bbfa/1.3.1

Boot2docker on Mac still has issue #49, this is Alpha2 after all :-)

Try some other Java EE 7 tests and file bugs here.

Enjoy!

Java EE 7 Hands-on Lab on WildFly and Docker (Tech Tip #61)

Java EE 7 Hands-on Lab has been delivered all around the world and is a pretty standard application that shows design patterns and anti-patterns for a typical Java EE 7 application. It shows how the following technologies can be used in a close-to-real-world application:

  • WebSocket 1.0
  • JSON Processing 1.0
  • Batch 1.0
  • Contexts & Dependency Injection 1.1
  • Java Message Service 2.0
  • Java API for RESTFul Services 2.0
  • Java Persistence API 2.0
  • Enterprise JavaBeans 3.1
  • JavaSever Faces 2.2

However the lab requires you to download NetBeans (Java EE 7 tooling) and WildFly or GlassFish (Java EE 7 runtime).

If you don’t want to follow the instructions and create the app, a pre-built solution zip file is available. But this still requires you to download Maven and build the app. You still have to download the runtime, which is pretty straight forward for WildFly, but still an extra task.

Maven step can be reduced using a pre-built WAR file, but runtime is still required.

Docker containers allows you to simplify application delivery by packaging all the key components together in an image. So how do you get the first feel of Java EE 7 hands-on lab with Docker ?

If you are new to Docker, Tech Tip #39 provide more background and details on how to get started. After initial setup, you can pull the Docker image that contains WildFly and pre-built Java EE 7 hands-on lab WAR file as shown:

docker pull arungupta/javaee7-hol

And then you can run it as:

docker run -it -p 80:8080 arungupta/javaee7-hol

Find out the IP address where your container is hosted using boot2docker ip command. And now access your Java EE 7 application at http://<IP>/movieplex7. The app would look like:

techtip61-output

Here is the complete log shown by the Docker container:

javaee7-hol> docker run -it -p 80:8080 arungupta/javaee7-hol
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

22:24:12,214 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
22:24:12,463 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
22:24:12,541 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.0.Final "Tweek" starting
22:24:13,566 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
22:24:13,586 INFO  [org.xnio] (MSC service thread 1-9) XNIO version 3.3.0.Final
22:24:13,595 INFO  [org.xnio.nio] (MSC service thread 1-9) XNIO NIO Implementation Version 3.3.0.Final
22:24:13,623 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 35) JBAS010280: Activating Infinispan subsystem.
22:24:13,631 INFO  [org.jboss.as.jacorb] (ServerService Thread Pool -- 36) JBAS016300: Activating JacORB Subsystem
22:24:13,650 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 34) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
22:24:13,678 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 51) JBAS013171: Activating Security Subsystem
22:24:13,682 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 46) JBAS011800: Activating Naming Subsystem
22:24:13,684 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 52) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
22:24:13,690 INFO  [org.jboss.as.security] (MSC service thread 1-6) JBAS013170: Current PicketBox version=4.0.21.Final
22:24:13,694 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-10) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)
22:24:13,706 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 42) JBAS012615: Activated the following JSF Implementations: [main]
22:24:13,764 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 54) JBAS015537: Activating WebServices Extension
22:24:13,826 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017502: Undertow 1.1.0.Final starting
22:24:13,827 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 53) JBAS017502: Undertow 1.1.0.Final starting
22:24:14,086 INFO  [org.jboss.remoting] (MSC service thread 1-9) JBoss Remoting version 4.0.6.Final
22:24:14,087 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 30) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
22:24:14,092 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-13) JBAS010417: Started Driver service with driver-name = h2
22:24:14,126 INFO  [org.jboss.as.naming] (MSC service thread 1-6) JBAS011802: Starting Naming Service
22:24:14,139 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-15) JBAS015400: Bound mail session [java:jboss/mail/Default]
22:24:14,316 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 53) JBAS017527: Creating file handler for path /opt/jboss/wildfly/welcome-content
22:24:14,343 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-9) JBAS017525: Started server default-server.
22:24:14,364 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017531: Host default-host starting
22:24:14,433 WARN  [jacorb.codeset] (MSC service thread 1-4) Warning - unknown codeset (ASCII) - defaulting to ISO-8859-1
22:24:14,462 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-9) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:8080
22:24:14,488 WARN  [org.jboss.as.messaging] (MSC service thread 1-6) JBAS011600: AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal
22:24:14,492 INFO  [org.jboss.as.jacorb] (MSC service thread 1-4) JBAS016330: CORBA ORB Service started
22:24:14,566 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221000: live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=/opt/jboss/wildfly/standalone/data/messagingjournal,bindingsDirectory=/opt/jboss/wildfly/standalone/data/messagingbindings,largeMessagesDirectory=/opt/jboss/wildfly/standalone/data/messaginglargemessages,pagingDirectory=/opt/jboss/wildfly/standalone/data/messagingpaging)
22:24:14,574 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221006: Waiting to obtain live lock
22:24:14,623 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
22:24:14,630 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221013: Using NIO Journal
22:24:14,664 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-8) JBAS015012: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
22:24:14,671 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-16) JBAS015876: Starting deployment of "movieplex7-1.0-SNAPSHOT.war" (runtime-name: "movieplex7-1.0-SNAPSHOT.war")
22:24:14,692 INFO  [org.jboss.as.jacorb] (MSC service thread 1-15) JBAS016328: CORBA Naming Service started
22:24:14,737 INFO  [io.netty.util.internal.PlatformDependent] (ServerService Thread Pool -- 56) Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system unstability.
22:24:14,771 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221043: Adding protocol support CORE
22:24:14,777 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221043: Adding protocol support AMQP
22:24:14,780 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221043: Adding protocol support STOMP
22:24:14,836 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221034: Waiting to obtain live lock
22:24:14,837 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221035: Live Server Obtained live lock
22:24:14,987 INFO  [org.jboss.messaging] (MSC service thread 1-4) JBAS011615: Registered HTTP upgrade for hornetq-remoting protocol handled by http-acceptor-throughput acceptor
22:24:14,987 INFO  [org.jboss.messaging] (MSC service thread 1-13) JBAS011615: Registered HTTP upgrade for hornetq-remoting protocol handled by http-acceptor acceptor
22:24:14,997 INFO  [org.jboss.as.jpa] (MSC service thread 1-16) JBAS011401: Read persistence.xml for movieplex7PU
22:24:15,055 INFO  [org.jboss.ws.common.management] (MSC service thread 1-9) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final
22:24:15,082 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221007: Server is now live
22:24:15,083 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221001: HornetQ Server version 2.4.5.FINAL (Wild Hornet, 124) [71b2a3db-7ccd-11e4-8f44-5d96c66ef94c] 
22:24:15,084 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 57) JBAS011409: Starting Persistence Unit (phase 1 of 2) Service 'movieplex7-1.0-SNAPSHOT.war#movieplex7PU'
22:24:15,094 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221003: trying to deploy queue jms.queue.ExpiryQueue
22:24:15,100 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 57) HHH000204: Processing PersistenceUnitInfo [
        name: movieplex7PU
        ...]
22:24:15,161 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 56) JBAS011601: Bound messaging object to jndi name java:/jms/queue/ExpiryQueue
22:24:15,177 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 59) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory
22:24:15,180 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 60) HQ221003: trying to deploy queue jms.queue.DLQ
22:24:15,183 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 60) JBAS011601: Bound messaging object to jndi name java:/jms/queue/DLQ
22:24:15,193 INFO  [org.hornetq.jms.server] (ServerService Thread Pool -- 58) HQ121005: Invalid "host" value "0.0.0.0" detected for "http-connector" connector. Switching to "e953a86d3fc0". If this new address is incorrect please manually configure the connector to use the proper one.
22:24:15,194 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 57) HHH000412: Hibernate Core {4.3.7.Final}
22:24:15,194 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 58) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
22:24:15,197 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 57) HHH000206: hibernate.properties not found
22:24:15,198 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 57) HHH000021: Bytecode provider name : javassist
22:24:15,200 INFO  [org.jboss.as.connector.deployment] (MSC service thread 1-12) JBAS010406: Registered connection factory java:/JmsXA
22:24:15,234 INFO  [org.hornetq.ra] (MSC service thread 1-12) HornetQ resource adaptor started
22:24:15,235 INFO  [org.jboss.as.connector.services.resourceadapters.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-12) IJ020002: Deployed: file://RaActivatorhornetq-ra
22:24:15,238 INFO  [org.jboss.as.connector.deployment] (MSC service thread 1-11) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]
22:24:15,238 INFO  [org.jboss.as.messaging] (MSC service thread 1-6) JBAS011601: Bound messaging object to jndi name java:jboss/DefaultJMSConnectionFactory
22:24:15,355 INFO  [org.jboss.weld.deployer] (MSC service thread 1-11) JBAS016002: Processing weld deployment movieplex7-1.0-SNAPSHOT.war
22:24:15,405 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-11) HV000001: Hibernate Validator 5.1.3.Final
22:24:15,477 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-11) JNDI bindings for session bean named ShowTimingFacadeREST in deployment unit deployment "movieplex7-1.0-SNAPSHOT.war" are as follows:

        java:global/movieplex7-1.0-SNAPSHOT/ShowTimingFacadeREST!org.javaee7.movieplex7.rest.ShowTimingFacadeREST
        java:app/movieplex7-1.0-SNAPSHOT/ShowTimingFacadeREST!org.javaee7.movieplex7.rest.ShowTimingFacadeREST
        java:module/ShowTimingFacadeREST!org.javaee7.movieplex7.rest.ShowTimingFacadeREST
        java:global/movieplex7-1.0-SNAPSHOT/ShowTimingFacadeREST
        java:app/movieplex7-1.0-SNAPSHOT/ShowTimingFacadeREST
        java:module/ShowTimingFacadeREST

22:24:15,478 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-11) JNDI bindings for session bean named TheaterFacadeREST in deployment unit deployment "movieplex7-1.0-SNAPSHOT.war" are as follows:

        java:global/movieplex7-1.0-SNAPSHOT/TheaterFacadeREST!org.javaee7.movieplex7.rest.TheaterFacadeREST
        java:app/movieplex7-1.0-SNAPSHOT/TheaterFacadeREST!org.javaee7.movieplex7.rest.TheaterFacadeREST
        java:module/TheaterFacadeREST!org.javaee7.movieplex7.rest.TheaterFacadeREST
        java:global/movieplex7-1.0-SNAPSHOT/TheaterFacadeREST
        java:app/movieplex7-1.0-SNAPSHOT/TheaterFacadeREST
        java:module/TheaterFacadeREST

22:24:15,478 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-11) JNDI bindings for session bean named MovieFacadeREST in deployment unit deployment "movieplex7-1.0-SNAPSHOT.war" are as follows:

        java:global/movieplex7-1.0-SNAPSHOT/MovieFacadeREST!org.javaee7.movieplex7.rest.MovieFacadeREST
        java:app/movieplex7-1.0-SNAPSHOT/MovieFacadeREST!org.javaee7.movieplex7.rest.MovieFacadeREST
        java:module/MovieFacadeREST!org.javaee7.movieplex7.rest.MovieFacadeREST
        java:global/movieplex7-1.0-SNAPSHOT/MovieFacadeREST
        java:app/movieplex7-1.0-SNAPSHOT/MovieFacadeREST
        java:module/MovieFacadeREST

22:24:15,479 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-11) JNDI bindings for session bean named SalesFacadeREST in deployment unit deployment "movieplex7-1.0-SNAPSHOT.war" are as follows:

        java:global/movieplex7-1.0-SNAPSHOT/SalesFacadeREST!org.javaee7.movieplex7.rest.SalesFacadeREST
        java:app/movieplex7-1.0-SNAPSHOT/SalesFacadeREST!org.javaee7.movieplex7.rest.SalesFacadeREST
        java:module/SalesFacadeREST!org.javaee7.movieplex7.rest.SalesFacadeREST
        java:global/movieplex7-1.0-SNAPSHOT/SalesFacadeREST
        java:app/movieplex7-1.0-SNAPSHOT/SalesFacadeREST
        java:module/SalesFacadeREST

22:24:15,479 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-11) JNDI bindings for session bean named TimeslotFacadeREST in deployment unit deployment "movieplex7-1.0-SNAPSHOT.war" are as follows:

        java:global/movieplex7-1.0-SNAPSHOT/TimeslotFacadeREST!org.javaee7.movieplex7.rest.TimeslotFacadeREST
        java:app/movieplex7-1.0-SNAPSHOT/TimeslotFacadeREST!org.javaee7.movieplex7.rest.TimeslotFacadeREST
        java:module/TimeslotFacadeREST!org.javaee7.movieplex7.rest.TimeslotFacadeREST
        java:global/movieplex7-1.0-SNAPSHOT/TimeslotFacadeREST
        java:app/movieplex7-1.0-SNAPSHOT/TimeslotFacadeREST
        java:module/TimeslotFacadeREST

22:24:15,679 INFO  [org.jboss.as.messaging] (MSC service thread 1-10) JBAS011601: Bound messaging object to jndi name java:global/jms/pointsQueue
22:24:15,753 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016005: Starting Services for CDI deployment: movieplex7-1.0-SNAPSHOT.war
22:24:15,787 INFO  [org.jboss.weld.Version] (MSC service thread 1-3) WELD-000900: 2.2.6 (Final)
22:24:15,823 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 57) HQ221003: trying to deploy queue jms.queue.movieplex7-1.0-SNAPSHOT_movieplex7-1.0-SNAPSHOT_movieplex7-1.0-SNAPSHOT_java:global/jms/pointsQueue
22:24:15,825 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016008: Starting weld service for deployment movieplex7-1.0-SNAPSHOT.war
22:24:15,995 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 57) JBAS011409: Starting Persistence Unit (phase 2 of 2) Service 'movieplex7-1.0-SNAPSHOT.war#movieplex7PU'
22:24:16,097 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 57) HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
22:24:16,403 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 57) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
22:24:16,409 WARN  [org.hibernate.dialect.H2Dialect] (ServerService Thread Pool -- 57) HHH000431: Unable to determine H2 database version, certain features may not work
22:24:16,551 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 57) HHH000397: Using ASTQueryTranslatorFactory
22:24:17,005 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 57) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
22:24:17,006 WARN  [org.hibernate.dialect.H2Dialect] (ServerService Thread Pool -- 57) HHH000431: Unable to determine H2 database version, certain features may not work
22:24:17,014 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 57) Unable to execute JPA schema generation drop command [DROP TABLE SALES]
22:24:17,015 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 57) Unable to execute JPA schema generation drop command [DROP TABLE POINTS]
22:24:17,015 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 57) Unable to execute JPA schema generation drop command [DROP TABLE SHOW_TIMING]
22:24:17,015 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 57) Unable to execute JPA schema generation drop command [DROP TABLE MOVIE]
22:24:17,016 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 57) Unable to execute JPA schema generation drop command [DROP TABLE TIMESLOT]
22:24:17,016 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 57) Unable to execute JPA schema generation drop command [DROP TABLE THEATER]
22:24:18,043 INFO  [io.undertow.websockets.jsr] (MSC service thread 1-10) UT026003: Adding annotated server endpoint class org.javaee7.movieplex7.chat.ChatServer for path /websocket
22:24:18,144 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-10) Initializing Mojarra 2.2.8-jbossorg-1 20140822-1131 for context '/movieplex7'
22:24:18,593 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-10) Monitoring file:/opt/jboss/wildfly/standalone/tmp/vfs/temp/tempcccef9c92c7b9e85/movieplex7-1.0-SNAPSHOT.war-fb17dc17ca73dfb8/WEB-INF/faces-config.xml for modifications
22:24:19,013 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-10) Deploying javax.ws.rs.core.Application: class org.javaee7.movieplex7.rest.ApplicationConfig
22:24:19,013 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-10) Adding provider class org.javaee7.movieplex7.json.MovieWriter from Application class org.javaee7.movieplex7.rest.ApplicationConfig
22:24:19,013 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-10) Adding class resource org.javaee7.movieplex7.rest.SalesFacadeREST from Application class org.javaee7.movieplex7.rest.ApplicationConfig
22:24:19,014 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-10) Adding class resource org.javaee7.movieplex7.rest.MovieFacadeREST from Application class org.javaee7.movieplex7.rest.ApplicationConfig
22:24:19,014 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-10) Adding class resource org.javaee7.movieplex7.rest.ShowTimingFacadeREST from Application class org.javaee7.movieplex7.rest.ApplicationConfig
22:24:19,014 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-10) Adding provider class org.javaee7.movieplex7.json.MovieReader from Application class org.javaee7.movieplex7.rest.ApplicationConfig
22:24:19,014 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-10) Adding class resource org.javaee7.movieplex7.rest.TimeslotFacadeREST from Application class org.javaee7.movieplex7.rest.ApplicationConfig
22:24:19,014 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-10) Adding class resource org.javaee7.movieplex7.rest.TheaterFacadeREST from Application class org.javaee7.movieplex7.rest.ApplicationConfig
22:24:19,118 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-10) JBAS017534: Registered web context: /movieplex7
22:24:19,166 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 31) JBAS018559: Deployed "movieplex7-1.0-SNAPSHOT.war" (runtime-name : "movieplex7-1.0-SNAPSHOT.war")
22:24:19,187 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
22:24:19,188 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
22:24:19,188 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 7285ms - Started 400 of 452 services (104 services are lazy, passive or on-demand)

Source code for this Dockerfile is pretty straight forward and at github.com/arun-gupta/docker-images/blob/master/javaee7-hol/Dockerfile.

Enjoy!

 

jOOQ and how it relates to JDBC, Java EE, Hibernate, etc (Hanginar #2)

Following up from Hanginar #1, this latest hanginar with Lukas Eder (@lukaseder) share more details about jOOQ.

Learn all about:

  • What is jOOQ ?
  • Why JOOQ when there is JDBC and JPA ?
  • How does it fit with Java EE apps ? Does it uses underlying JPA persistence provider or some other connection ?
  • Pros/cons over JPA ? Pure Hibernate ?
  • How well does it scale ?
  • Show code sample in a Java EE application
  • jOOQ for CRUD-based or domain-rich application ?
  • How can eventually all the work in jOOQ be integrated in JPA and be standardized ? Or would it be more of JDBC ?

Many thanks to Lukas Eder (@lukaseder) for all the great work on jOOQ and participating in this series!

A tentative list of speakers is identified at github.com/javaee-samples/webinars. Each speaker is assigned an issue which allows you to ask questions. Feel free to file an issue for any other speaker that should be on the list.

Remove Docker image and container with a criteria (Tech Tip #60)

You have installed multiple Docker images and would like to clean them up using rmi command. So, you list all the images as:

~> docker images --no-trunc
REPOSITORY                 TAG                 IMAGE ID                                                           CREATED             VIRTUAL SIZE
mysql                      latest              98840bbb442c7dc3640ffe3a8ec45d3fee934c2f6d85daaaa2edf65b380485a0   25 hours ago        236 MB
wildfly-centos             latest              fc378232f03d04bff96987f4c23969461582f73c3a7b473a7cb823ac67939f48   5 days ago          619.6 MB
arungupta/wildfly-centos   latest              e4f1dbdff18956621aa48a83e5b05df309ee002c3668fa452f1235465d881020   6 days ago          619.6 MB
wildfly-ubuntu             latest              a2e96e76eb10f4df87d01965ce4df5310de6f9f3927aceb7f5642393050e8752   7 days ago          749.5 MB
registry                   latest              7e2db37c6564bf030e6c5af9725bf9f9a8196846e3a77a51e201fc97871e2e60   2 weeks ago         411.6 MB
centos                     latest              ae0c2d0bdc100993f7093400f96e9abab6ddd9a7c56b0ceba47685df5a8fe906   4 weeks ago         224 MB
jboss/wildfly              latest              365390553f925f96f8c00f79525ad101847de7781bb4fec23b1188f25fe99a6a   5 weeks ago         948.7 MB
centos/wildfly             latest              1de9304f58bbc2d401b4dcbba6fc686bdd6f6bff473fe486e7cb905c02163b1a   6 weeks ago         606.6 MB

Then try to remove the “arungupta/wildfly-centos” image as shown below, but get an error:

~> docker rmi e4f1dbdff18956621aa48a83e5b05df309ee002c3668fa452f1235465d881020
Error response from daemon: Conflict, cannot delete e4f1dbdff189 because the container bafc2b3327a4 is using it, use -f to force
2014/12/02 12:56:53 Error: failed to remove one or more images

So you follow the recommendation of using -f switch but get another error:

~> docker rmi -f e4f1dbdff18956621aa48a83e5b05df309ee002c3668fa452f1235465d881020
Error response from daemon: No such id: c345720579e024df4f6d28d2062fda64b7743f7dbb214136d4d2285bc3afc95b
2014/12/02 12:56:55 Error: failed to remove one or more images

What do you do ?

This message indicates that the image is used by one of the containers and that’s why could not be removed. The error message is very ambiguous and a #9458 has been filed for the same.

In the meanwhile, an easy way to solve this is to list all the containers as shown:

CONTAINER ID        IMAGE                             COMMAND                CREATED             STATUS                      PORTS                NAMES
bafc2b3327a4        arungupta/wildfly-centos:latest   "/opt/jboss/wildfly/   4 days ago                                                           boring_ptolemy        
bfe71d92a612        arungupta/wildfly-centos:latest   "/opt/jboss/wildfly/   4 days ago                                                           agitated_einstein     
e1c0965d202c        arungupta/wildfly-centos:latest   "/opt/jboss/wildfly/   4 days ago                                                           thirsty_blackwell     
ddc400c26f1a        mysql:latest                      "/entrypoint.sh mysq   5 days ago          Exited (0) 27 minutes ago   3306/tcp             sample-mysql          
05c741b5e22f        wildfly-centos:latest             "/opt/jboss/wildfly/   5 days ago          Exited (130) 5 days ago                          agitated_lalande      
ff10b83d6c17        arungupta/wildfly-centos:latest   "/opt/jboss/wildfly/   5 days ago                                                           insane_wilson         
b2774b17460c        arungupta/wildfly-centos:latest   "/opt/jboss/wildfly/   5 days ago                                                           goofy_pasteur         
2d64f4eb8fb9        arungupta/wildfly-centos:latest   "/opt/jboss/wildfly/   5 days ago                                                           focused_lalande       
c3f61947671a        arungupta/wildfly-centos:latest   "/opt/jboss/wildfly/   5 days ago                                                           silly_ardinghelli     
ac6f29b92c7a        arungupta/wildfly-centos:latest   "/opt/jboss/wildfly/   5 days ago                                                           stoic_leakey          
fc16f3f8c139        wildfly-centos:latest             "/opt/jboss/wildfly/   5 days ago                                                           desperate_babbage     
4555628a5d0a        wildfly-centos:latest             "/opt/jboss/wildfly/   5 days ago          Exited (-1) 4 days ago                           sharp_bardeen         
3bdae1d2527a        wildfly-centos:latest             "/opt/jboss/wildfly/   5 days ago          Exited (130) 5 days ago                          sick_lovelace         
2697c769c2ee        wildfly-centos:latest             "/opt/jboss/wildfly/   5 days ago                                                           thirsty_fermat        
f8c686d1d6be        wildfly-centos:latest             "/opt/jboss/wildfly/   5 days ago          Exited (130) 5 days ago                          cranky_fermat         
a1945f2ca473        wildfly-centos:latest             "/opt/jboss/wildfly/   5 days ago          Exited (-1) 4 days ago                           suspicious_turing     
31b9c4df0633        arungupta/wildfly-centos:latest   "/opt/jboss/wildfly/   5 days ago                                                           distracted_franklin   
cd8dad2b1e22        c345720579e0                      "/bin/sh -c '#(nop)    5 days ago                                                           cocky_blackwell       

There are lots of containers that are using “arungupta/wildfly-centos” image but none of them seem to be running. If there are any containers that are running then you need to stop them as:

docker rm $(docker stop $(docker ps -q))

Remove the containers that are using this image as:

docker ps -a | grep arungupta/wildfly-centos | awk '{print $1}' | xargs docker rm
bafc2b3327a4
bfe71d92a612
e1c0965d202c
ff10b83d6c17
b2774b17460c
2d64f4eb8fb9
ac6f29b92c7a
31b9c4df0633

The criteria here is specified as a grep pattern.

docker ps command has other options to specify criteria as well such as only the latest created containers or containers in a particular status. For example, containers that exited with status -1 can be seen as:

~> docker ps -a -f "exited=-1"
CONTAINER ID        IMAGE                   COMMAND                CREATED             STATUS                       PORTS               NAMES
68aca76aa690        wildfly-centos:latest   "/opt/jboss/wildfly/   39 minutes ago      Exited (-1) 37 minutes ago                       insane_yonath

All running containers, as opposed to meeting a specific criteria, can be removed as:

docker rm $(docker ps -aq)

And now the image can be easily removed as

~> docker rmi e4f1dbdff189
Untagged: arungupta/wildfly-centos:latest
Deleted: e4f1dbdff18956621aa48a83e5b05df309ee002c3668fa452f1235465d881020
Deleted: ad2899e176a2e73acbcf61909426786eaa195fcea7fb0aa27061431a3aae6633

Just like removing all containers, all images can be removed as:

docker rmi $(docker images -q)

Enjoy!

Docker Common Commands Cheatsheet (Tech Tip #59)

Docker CLI provides a comprehensive set of commands. Here is a quick cheat sheet of the commonly used commands:

Purpose Command
Build an image docker build –rm=true .
Install an image docker pull ${IMAGE}
List of installed images docker images
List of installed images (detailed listing) docker images –no-trunc
Remove an image docker rmi ${IMAGE_ID}
Remove all untagged images docker rmi $(docker images | grep “^” | awk “{print $3}”)
Remove all images docker rm $(docker ps -aq)
Run a container docker run
List containers docker ps
Stop a container docker stop ${CID}
Find IP address of the container docker inspect –format ‘{{ .NetworkSettings.IPAddress }}’ ${CID}
Attach to a container docker attach ${CID}
Remove a container docker rm ${CID}
Remove all containers docker rm $(docker ps -aq)

What other commands do you use commonly ?

Pushing Docker images to Registry (Tech Tip #58)

Tech Tip #57 explained how to create your own Docker images. That particular blog specifically showed how to build your own WildFly Docker images on CentOS and Ubuntu. Now you are ready to share your images with rest of the world. That’s where Docker Hub comes in handy.

Docker Hub is the “distribution component” of Docker, or a place to store and search images. From the Getting Started with Docker Hub docs …

The Docker Hub is a centralized resource for working with Docker and its components. Docker Hub helps you collaborate with colleagues and get the most out of Docker.

Starting and pushing images to with Docker Hub is pretty straight forward.

  • Pushing images to Docker Hub require an account. It can be created as explained here. Or rather easily by using docker login command.
    wildfly-centos> docker login
    Username: arungupta
    Password: 
    Email: [email protected]
    Login Succeeded

    Searching on WildFly shows there are 72 images:

    wildfly-centos> docker search wildfly
    NAME                                     DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    jboss/wildfly                            WildFly application server image                42                   [OK]
    sewatech/wildfly                         Debian + WildFly 8.1.0.Final with OpenJDK ...   1                    [OK]
    kamcord/wildfly                                                                          1                    
    openshift/wildfly-8-centos                                                               1                    [OK]
    abstractj/wildfly                        AeroGear Wildfly Docker image                   1                    
    jsightler/wildfly_nightly                Nightly build from wildfly's github master...   1                    
    centos/wildfly                           CentOS based WildFly Docker image               1                    
    aerogear/unifiedpush-wildfly                                                             1                    [OK]
    t0nyhays/wildfly                                                                         1                    [OK]
    tsuckow/wildfly-propeller                Dockerization of my application *Propeller...   0                    [OK]
    n3ziniuka5/wildfly                                                                       0                    [OK]
    snasello/wildfly                                                                         0                    [OK]
    jboss/keycloak-adapter-wildfly                                                           0                    [OK]
    emsouza/wildfly                                                                          0                    [OK]
    sillenttroll/wildfly-java-8              WildFly container with java 8                   0                    [OK]
    jboss/switchyard-wildfly                                                                 0                    [OK]
    n3ziniuka5/wildfly-jrebel                                                                0                    [OK]
    dfranssen/docker-wildfly                                                                 0                    [OK]
    wildflyext/wildfly-camel                 WildFly with Camel Subsystem                    0                    
    ianblenke/wildfly                                                                        0                    [OK]
    arcamael/docker-wildfly                                                                  0                    [OK]
    dmartin/wildfly                                                                          0                    [OK]
    pires/wildfly-cluster-backend                                                            0                    [OK]
    aerogear/push-quickstarts-wildfly-dev                                                    0                    [OK]
    faga/wildfly                             Wildfly application server with ubuntu.         0                    
    abstractj/unifiedpush-wildfly            AeroGear Wildfly Docker image                   0                    
    murad/wildfly                            - oficial centos image - java JDK "1.8.0_0...   0                    
    aerogear/unifiedpush-wildfly-dev                                                         0                    [OK]
    ianblenke/wildfly-cluster                                                                0                    [OK]
    blackhm/wildfly                                                                          0                    
    khipu/wildfly8                                                                           0                    [OK]
    rowanto/docker-wheezy-wildfly-java8                                                      0                    [OK]
    ordercloud/wildfly                                                                       0                    
    lavaliere/je-wildfly                     A Jenkins Enterprise demo master with a Wi...   0                    
    adorsys/wildfly                          Ubuntu - Wildfly - Base Image                   0                    
    akalliya/wildfly                                                                         0                    
    lavaliere/joc-wildfly                    Jenkins Operations Center master with an a...   0                    
    tdiesler/wildfly                                                                         0                    
    apiman/on-wildfly8                                                                       0                    [OK]
    rowanto/docker-wheezy-wildfly-java8-ex                                                   0                    [OK]
    arcamael/blog-wildfly                                                                    0                    
    lavaliere/wildfly                                                                        0                    
    jfaerman/wildfly                                                                         0                    
    yntelectual/wildfly                                                                      0                    
    svenvintges/wildfly                                                                      0                    
    dbrotsky/wildfly                                                                         0                    
    luksa/wildfly                                                                            0                    
    tdiesler/wildfly-camel                                                                   0                    
    blackhm/wildfly-junixsocket                                                              0                    
    abstractj/unifiedpush-wildfly-dev        AeroGear UnifiedPush server developer envi...   0                    
    abstractj/push-quickstarts-wildfly-dev   AeroGear UnifiedPush Quickstarts developer...   0                    
    bn3t/wildfly-wicket-examples             An image to run the wicket-examples on wil...   0                    
    lavaliere/wildfly-1                                                                      0                    
    munchee13/wildfly-node                                                                   0                    
    munchee13/wildfly-manager                                                                0                    
    munchee13/wildfly-dandd                                                                  0                    
    munchee13/wildfly-admin                                                                  0                    
    bparees/wildfly-8-centos                                                                 0                    
    lecoz/wildflysiolapie                    fedora latest, jdk1.8.0_25, wildfly-8.1.0....   0                    
    lecoz/wildflysshsiolapie                 wildfly 8.1.0.Final, jdk1.8.0_25, sshd, fe...   0                    
    wildflyext/example-camel-rest                                                            0                    
    pepedigital/wildfly                                                                      0                    [OK]
    tsuckow/wildfly                          JBoss Wildfly 8.1.0.Final standalone mode ...   0                    [OK]
    mihahribar/wildfly                       Dockerfile for Wildfly running on Ubuntu 1...   0                    [OK]
    hpehl/wildfly-domain                     Dockerfiles based on "jboss/wildfly" to se...   0                    [OK]
    raynera/wildfly                                                                          0                    [OK]
    hpehl/wildfly-standalone                 Dockerfile based on jboss/wildfly to setup...   0                    [OK]
    aerogear/wildfly                                                                         0                    [OK]
    piegsaj/wildfly                                                                          0                    [OK]
    wildflyext/wildfly                       Tagged versions JBoss WildFly                   0

    Official images are tagged jboss/wildfly.

  • In order to push your own image, it needs to be built as a named image otherwise you’ll get an error as shown:
    2014/11/26 09:59:37 You cannot push a "root" repository. Please rename your repository in <user>/<repo> (ex: arungupta/wildfly-centos)

    This can be easily done as shown:

    wildfly-centos> docker build -t="arungupta/wildfly-centos" .
    Sending build context to Docker daemon 4.096 kB
    Sending build context to Docker daemon 
    Step 0 : FROM centos
     ---> ae0c2d0bdc10
    Step 1 : MAINTAINER Arun Gupta <[email protected]>
     ---> Using cache
     ---> e490dfcb3685
    Step 2 : RUN yum -y update && yum clean all
     ---> Using cache
     ---> f212cb9dbcf5
    Step 3 : RUN yum -y install xmlstarlet saxon augeas bsdtar unzip && yum clean all
     ---> Using cache
     ---> 28b11e6151f0
    Step 4 : RUN groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss
     ---> Using cache
     ---> 73603eab89b7
    Step 5 : WORKDIR /opt/jboss
     ---> Using cache
     ---> 9a661ae4341b
    Step 6 : USER jboss
     ---> Using cache
     ---> 6265153611c7
    Step 7 : USER root
     ---> Using cache
     ---> 12ed28a7acb7
    Step 8 : RUN yum -y install java-1.7.0-openjdk-devel && yum clean all
     ---> Using cache
     ---> 44c4bb92fa11
    Step 9 : USER jboss
     ---> Using cache
     ---> 930cb2a860f7
    Step 10 : ENV JAVA_HOME /usr/lib/jvm/java
     ---> Using cache
     ---> fff2c21b0a71
    Step 11 : ENV WILDFLY_VERSION 8.2.0.Final
     ---> Using cache
     ---> b7b7ca7a9172
    Step 12 : RUN cd $HOME && curl -O http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.zip && unzip wildfly-$WILDFLY_VERSION.zip && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly && rm wildfly-$WILDFLY_VERSION.zip
     ---> Using cache
     ---> a1bc79a43c77
    Step 13 : ENV JBOSS_HOME /opt/jboss/wildfly
     ---> Using cache
     ---> d46fdd618d55
    Step 14 : EXPOSE 8080 9990
     ---> Running in 9c2c2a5ef41c
     ---> 8988c8cbc051
    Removing intermediate container 9c2c2a5ef41c
    Step 15 : CMD /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0
     ---> Running in 9e28c3449ec1
     ---> d989008d1f84
    Removing intermediate container 9e28c3449ec1
    Successfully built d989008d1f84

    docker build command builds the image, -t specifies the repository name to be applied to the resulting image.

  • Once the image is built, it can be verified as:
    wildfly-centos> docker images
    REPOSITORY                 TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    arungupta/wildfly-centos   latest              d989008d1f84        14 hours ago        619.6 MB
    wildfly-ubuntu             latest              a2e96e76eb10        43 hours ago        749.5 MB
    <none>                     <none>              0281986b0ed8        44 hours ago        749.5 MB
    <none>                     <none>              1a5e1aeadc85        44 hours ago        607.7 MB
    wildfly-centos             latest              97c8780a7d6a        45 hours ago        619.6 MB
    registry                   latest              7e2db37c6564        13 days ago         411.6 MB
    centos                     latest              ae0c2d0bdc10        3 weeks ago         224 MB
    jboss/wildfly              latest              365390553f92        4 weeks ago         948.7 MB
    ubuntu                     latest              5506de2b643b        4 weeks ago         199.3 MB

    Notice the first line shows the named image arungupta/wildfly-centos.

  • This image can then be pushed to Docker Hub as:
    wildfly-centos> docker push arungupta/wildfly-centos
    The push refers to a repository [arungupta/wildfly-centos] (len: 1)
    Sending image list
    Pushing repository arungupta/wildfly-centos (1 tags)
    511136ea3c5a: Image already pushed, skipping 
    5b12ef8fd570: Image already pushed, skipping 
    ae0c2d0bdc10: Image already pushed, skipping 
    e490dfcb3685: Image successfully pushed 
    f212cb9dbcf5: Image successfully pushed 
    28b11e6151f0: Image successfully pushed 
    73603eab89b7: Image successfully pushed 
    9a661ae4341b: Image successfully pushed 
    6265153611c7: Image successfully pushed 
    12ed28a7acb7: Image successfully pushed 
    44c4bb92fa11: Image successfully pushed 
    930cb2a860f7: Image successfully pushed 
    fff2c21b0a71: Image successfully pushed 
    b7b7ca7a9172: Image successfully pushed 
    a1bc79a43c77: Image successfully pushed 
    d46fdd618d55: Image successfully pushed 
    8988c8cbc051: Image successfully pushed 
    d989008d1f84: Image successfully pushed 
    Pushing tag for rev [d989008d1f84] on {https://cdn-registry-1.docker.io/v1/repositories/arungupta/wildfly-centos/tags/latest}
  • And you can verify this by pulling the image:
    wildfly-centos> docker pull arungupta/wildfly-centos
    Pulling repository arungupta/wildfly-centos
    d989008d1f84: Download complete 
    511136ea3c5a: Download complete 
    5b12ef8fd570: Download complete 
    ae0c2d0bdc10: Download complete 
    e490dfcb3685: Download complete 
    f212cb9dbcf5: Download complete 
    28b11e6151f0: Download complete 
    73603eab89b7: Download complete 
    9a661ae4341b: Download complete 
    6265153611c7: Download complete 
    12ed28a7acb7: Download complete 
    44c4bb92fa11: Download complete 
    930cb2a860f7: Download complete 
    fff2c21b0a71: Download complete 
    b7b7ca7a9172: Download complete 
    a1bc79a43c77: Download complete 
    d46fdd618d55: Download complete 
    8988c8cbc051: Download complete 
    Status: Image is up to date for arungupta/wildfly-centos:latest

Enjoy!

 

Create your own Docker image (Tech Tip #57)

Docker simplifies software delivery by making it easy to build and share images that contain your application’s entire environment, i.e. operating system, JDK, database, WAR file, specific tuning required for your application, etc.

There are three main components of Docker:

  • Docker images are “build component” – a read-only template of application operating system.
  • Containers are “run component” – a runtime representation created from images.
  • Registry are “distribution component” – a place to store and distribute images.

Several JBoss projects are available as Docker images at www.jboss.org/docker. Tech Tip #39 explained how to get started with Docker on Mac. It also explained how to start the official WildFly Docker image.

Docker image is made up of multiple layers where each layer provides some functionality, and a higher layer can add functionality on top of it. For example, Docker mounts the root filesystem as read-only layer and then adds a read-write layer on top of it. All these layers are combined together using Union Mount to provide application operating environment.

The complete history of how the WildFly image was built can be seen as:

docker history --no-trunc=true jboss/wildfly
IMAGE                                                              CREATED             CREATED BY                                                                                                                                                                   SIZE
365390553f925f96f8c00f79525ad101847de7781bb4fec23b1188f25fe99a6a   3 weeks ago         /bin/sh -c #(nop) CMD [/opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0]                                                                                                      0 B
d7fccab36b8f5a324ef8dd017c8964f2de7839379503021f15502ba3f0b908bd   3 weeks ago         /bin/sh -c #(nop) EXPOSE map[8080/tcp:{} 9990/tcp:{}]                                                                                                                        0 B
184d6d02f340455d33d226d6467484027d0763964a586ae9ada1782262299a74   3 weeks ago         /bin/sh -c #(nop) ENV JBOSS_HOME=/opt/jboss/wildfly                                                                                                                          0 B
57ada25ecdd03191355ec1c8f5f1a4e05b3e152709c9b603d5ed5fb0c4d53853   3 weeks ago         /bin/sh -c cd $HOME && curl http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz | tar zx && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly   135 MB
59ec65b61fba2b6ada099abe3a9a30d05ffb71370b43dfbd0208fd4f5a34c005   3 weeks ago         /bin/sh -c #(nop) ENV WILDFLY_VERSION=8.1.0.Final                                                                                                                            0 B
90832e1f0bb9e9f98ecd42f6df6b124c1e6768babaddc23d646cd75c7b2fddec   5 weeks ago         /bin/sh -c #(nop) ENV JAVA_HOME=/usr/lib/jvm/java                                                                                                                            0 B
72d585299bb5c5c1c326422cfffadc93d8bb4020f35bf072b2d91d287967807a   5 weeks ago         /bin/sh -c #(nop) USER jboss                                                                                                                                                 0 B
e02bdb6c4ed5436da02c958d302af5f06c1ebb1821791f60d45e190ebb55130f   5 weeks ago         /bin/sh -c yum -y install java-1.7.0-openjdk-devel && yum clean all                                                                                                          217.2 MB
b17a20d6f5f8e7ed0a1dba277acd3f854c531b0476b03d63a8f0df4caf78c763   5 weeks ago         /bin/sh -c #(nop) USER root                                                                                                                                                  0 B
7759146eab1a3aa5ba5ed12483d03e64a6bf1061a383d5713a5e21fc40554457   5 weeks ago         /bin/sh -c #(nop) MAINTAINER Marek Goldmann <[email protected]>                                                                                                            0 B
2ea8562cac7c25a308b4565b66d4f7e11a1d2137a599ef2b32ed23c78f0a0378   5 weeks ago         /bin/sh -c #(nop) USER jboss                                                                                                                                                 0 B
4d37cbbfc67dd508e682a5431a99d8c1feba1bd8352ffd3ea794463d9cfa81cc   5 weeks ago         /bin/sh -c #(nop) WORKDIR /opt/jboss                                                                                                                                         0 B
379edb00ab0764276787ea777243990da697f2f93acb5d9166ff73ad01511a87   5 weeks ago         /bin/sh -c groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss                                                  295 kB
cd5bb934bb6755e910d19ac3ae4cfd09221aa2f98c3fbb51a7486991364dc1ae   5 weeks ago         /bin/sh -c yum -y install xmlstarlet saxon augeas bsdtar unzip && yum clean all                                                                                              21.35 MB
20a1abe1d9bfb9b1e46d5411abd5a38b6104a323b7c4fb5c0f1f161b8f7278c2   5 weeks ago         /bin/sh -c yum -y update && yum clean all                                                                                                                                    200.7 MB
1ef0a50fe8b1394d3626a7624a58b58cff9560ddb503743099a56bbe95ab481a   5 weeks ago         /bin/sh -c #(nop) MAINTAINER Marek Goldmann <[email protected]>                                                                                                            0 B
7d3f07f8de5fb3a20c6cb1e4447773a5741e3641c1aa093366eaa0fc690c6417   7 weeks ago         /bin/sh -c #(nop) ADD file:285fdeab65d637727f6b79392a309135494d2e6046c6cc2fbd2f23e43eaac69c in /                                                                             374.1 MB
782cf93a8f16d3016dae352188cd5cfedb6a15c37d4dbd704399f02d1bb89dab   7 weeks ago         /bin/sh -c #(nop) MAINTAINER Lokesh Mandvekar <[email protected]> - ./buildcontainers.sh                                                                                0 B
511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158   17 months ago                                                                                                                                                                                    0 B

The exact command issued at each layer is listed in this output. If you scroll to the far right then you can see the total space consumed by each layer as well. For example, Fedora is used as the base image and consumes ~574 MB of the total image, Open JDK 7 is taking 217.5 MB and WildFly is 135 MB.

Docker images are built by reading the instructions from Dockerfile. This is a text file that contains all the commands, in order, needed to build a given image. It adheres to a specific format and use a specific set of instructions. The vocabulary of commands is rather limited but serves the purpose well. The image can be built by giving the command docker build. Docker Tutorial provides complete instructions on how to create your own custom image.

The official WildFly Docker image is built using Fedora 20 as the base operating system. The Dockerfile can be seen at github.com/jboss-dockerfiles/wildfly/blob/master/Dockerfile. It uses  jboss/base-jdk:7 as the base image, which uses jboss/base as the base image. Dockerfile of jboss/base shows Fedora 20 is used as the base image.

An alternative is to build this image using CentOS or Ubuntu as a base image. Dockerfiles for these images are available at github.com/arun-gupta/docker-images/.

Starting boot2docker shows the output as:

bash
unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH
mkdir -p ~/.boot2docker
if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi
/usr/local/bin/boot2docker init 
/usr/local/bin/boot2docker up 
$(/usr/local/bin/boot2docker shellinit)
docker version
Last login: Mon Nov 24 11:03:33 on ttys006
hello arungupta
~> bash
~> unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH
~> mkdir -p ~/.boot2docker
~> if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi
~> /usr/local/bin/boot2docker init 
Virtual machine boot2docker-vm already exists
~> /usr/local/bin/boot2docker up 
Waiting for VM and Docker daemon to start...
.....................ooooooooooooooooo
Started.
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/key.pem

To connect the Docker client to the Docker daemon, please set:
    export DOCKER_HOST=tcp://192.168.59.103:2376
    export DOCKER_CERT_PATH=/Users/arungupta/.boot2docker/certs/boot2docker-vm
    export DOCKER_TLS_VERIFY=1

~> $(/usr/local/bin/boot2docker shellinit)
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/arungupta/.boot2docker/certs/boot2docker-vm/key.pem
~> docker version
Client version: 1.3.1
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 4e9bbfa
OS/Arch (client): darwin/amd64
Server version: 1.3.1
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 4e9bbfa

And then you can build the CentOS-based WildFly Docker image as shown below. Note this command is given from the “wildfly-centos” directory of github.com/arun-gupta/docker-images/. And so the Dockerfile is at github.com/arun-gupta/docker-images/blob/master/wildfly-centos/Dockerfile.

wildfly-centos> docker build -t wildfly-centos .
Sending build context to Docker daemon 4.096 kB
Sending build context to Docker daemon 
Step 0 : FROM centos
centos:latest: The image you are pulling has been verified
511136ea3c5a: Pull complete 
5b12ef8fd570: Pull complete 
ae0c2d0bdc10: Pull complete 
Status: Downloaded newer image for centos:latest
 ---> ae0c2d0bdc10
Step 1 : MAINTAINER Arun Gupta <[email protected]>
 ---> Running in 7fc52653d381
 ---> e490dfcb3685
Removing intermediate container 7fc52653d381
Step 2 : RUN yum -y update && yum clean all
 ---> Running in 90de23c9dde7
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.cc.columbia.edu
 * extras: centos.mirror.ndchost.com
 * updates: centos-distro.cavecreek.net
Resolving Dependencies
--> Running transaction check
---> Package tzdata.noarch 0:2014h-1.el7 will be updated
---> Package tzdata.noarch 0:2014j-1.el7_0 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch            Version                 Repository        Size
================================================================================
Updating:
 tzdata          noarch          2014j-1.el7_0           updates          434 k

Transaction Summary
================================================================================
Upgrade  1 Package

Total download size: 434 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/updates/packages/tzdata-2014j-1.el7_0.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for tzdata-2014j-1.el7_0.noarch.rpm is not installed
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-0.1406.el7.centos.2.5.x86_64 (@Updates/$releasever)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : tzdata-2014j-1.el7_0.noarch                                  1/2 
  Cleanup    : tzdata-2014h-1.el7.noarch                                    2/2 
  Verifying  : tzdata-2014j-1.el7_0.noarch                                  1/2 
  Verifying  : tzdata-2014h-1.el7.noarch                                    2/2 

Updated:
  tzdata.noarch 0:2014j-1.el7_0                                                 

Complete!
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
 ---> f212cb9dbcf5
Removing intermediate container 90de23c9dde7
Step 3 : RUN yum -y install xmlstarlet saxon augeas bsdtar unzip && yum clean all
 ---> Running in d4bd822933c8
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror-centos.hostingswift.com
 * extras: mirror.keystealth.org
 * updates: mirrors.advancedhosters.com
No package xmlstarlet available.
Resolving Dependencies
--> Running transaction check
---> Package augeas.x86_64 0:1.1.0-12.el7 will be installed
--> Processing Dependency: augeas-libs = 1.1.0-12.el7 for package: augeas-1.1.0-12.el7.x86_64

. . .

--> Processing Dependency: python-lxml for package: python-javapackages-3.4.1-6.el7_0.noarch
--> Running transaction check
---> Package python-lxml.x86_64 0:3.2.1-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                  Arch        Version                Repository    Size
================================================================================
Installing:
 augeas                   x86_64      1.1.0-12.el7           base          35 k
 bsdtar                   x86_64      3.1.2-7.el7            base          55 k

. . .

 python-javapackages      noarch      3.4.1-6.el7_0          updates       31 k
 python-lxml              x86_64      3.2.1-4.el7            base         758 k

Transaction Summary
================================================================================
Install  4 Packages (+9 Dependent packages)

Total download size: 4.2 M
Installed size: 8.0 M
Downloading packages:
--------------------------------------------------------------------------------
Total                                              188 kB/s | 4.2 MB  00:22     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : lzo-2.06-6.el7_0.2.x86_64                                   1/13 
  Installing : libxslt-1.1.28-5.el7.x86_64                                 

. . .

  Installing : unzip-6.0-13.el7.x86_64                                    13/13 
  Verifying  : augeas-1.1.0-12.el7.x86_64                                  1/13 

. . .

  Verifying  : javapackages-tools-3.4.1-6.el7_0.noarch                    13/13 

Installed:
  augeas.x86_64 0:1.1.0-12.el7            bsdtar.x86_64 0:3.1.2-7.el7          
  saxon.noarch 0:9.3.0.4-11.el7           unzip.x86_64 0:6.0-13.el7            

Dependency Installed:
  augeas-libs.x86_64 0:1.1.0-12.el7  bea-stax.noarch 0:1.2.0-9.el7              
  bea-stax-api.noarch 0:1.2.0-9.el7  javapackages-tools.noarch 0:3.4.1-6.el7_0  
  libarchive.x86_64 0:3.1.2-7.el7    libxslt.x86_64 0:1.1.28-5.el7              
  lzo.x86_64 0:2.06-6.el7_0.2        python-javapackages.noarch 0:3.4.1-6.el7_0 
  python-lxml.x86_64 0:3.2.1-4.el7  

Complete!
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
 ---> 28b11e6151f0
Removing intermediate container d4bd822933c8
Step 4 : RUN groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss
 ---> Running in 943c20ba5a51
 ---> 73603eab89b7
Removing intermediate container 943c20ba5a51
Step 5 : WORKDIR /opt/jboss
 ---> Running in 29c865c3109c
 ---> 9a661ae4341b
Removing intermediate container 29c865c3109c
Step 6 : USER jboss
 ---> Running in 7dfd8416ae2c
 ---> 6265153611c7
Removing intermediate container 7dfd8416ae2c
Step 7 : USER root
 ---> Running in a72588fba840
 ---> 12ed28a7acb7
Removing intermediate container a72588fba840
Step 8 : RUN yum -y install java-1.7.0-openjdk-devel && yum clean all
 ---> Running in 4efb3e17eb38
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.trouble-free.net
 * extras: centos.mirror.ndchost.com
 * updates: centos-distro.cavecreek.net
Resolving Dependencies
--> Running transaction check
---> Package java-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1.el7_0 will be installed

. . .

---> Package hwdata.noarch 0:0.252-7.3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                      Arch    Version                    Repository
                                                                           Size
================================================================================
Installing:
 java-1.7.0-openjdk-devel     x86_64  1:1.7.0.71-2.5.3.1.el7_0   updates  9.2 M
Installing for dependencies:
 alsa-lib                     x86_64  1.0.27.2-3.el7             base     389 k

. . .

144 k
 xorg-x11-font-utils          x86_64  1:7.5-18.1.el7             base      87 k
 xorg-x11-fonts-Type1         noarch  7.5-9.el7                  base     521 k

Transaction Summary
================================================================================
Install  1 Package (+73 Dependent packages)

Total download size: 49 M
Installed size: 181 M
Downloading packages:
--------------------------------------------------------------------------------
Total                                              1.7 MB/s |  49 MB  00:29     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : freetype-2.4.11-9.el7.x86_64                                1/74 
  Installing : libjpeg-turbo-1.2.90-5.el7.x86_64                           2/74 

. . .

73/74 
  Installing : 1:java-1.7.0-openjdk-devel-1.7.0.71-2.5.3.1.el7_0.x86_64   74/74 
  Verifying  : libsndfile-1.0.25-9.el7.x86_64                              1/74 
  Verifying  : libXfont-1.4.7-2.el7_0.x86_64                               2/74 
  Verifying  : kmod-14-9.el7.x86_64                                        

. . .

73/74 
  Verifying  : gdk-pixbuf2-2.28.2-4.el7.x86_64                            74/74 

Installed:
  java-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1.el7_0                      

Dependency Installed:
  alsa-lib.x86_64 0:1.0.27.2-3.el7                                              
  atk.x86_64 0:2.8.0-4.el7                                                      

. . .
                                          
  xorg-x11-font-utils.x86_64 1:7.5-18.1.el7                                     
  xorg-x11-fonts-Type1.noarch 0:7.5-9.el7                                       

Complete!
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
 ---> 44c4bb92fa11
Removing intermediate container 4efb3e17eb38
Step 9 : USER jboss
 ---> Running in 824d62c49182
 ---> 930cb2a860f7
Removing intermediate container 824d62c49182
Step 10 : ENV JAVA_HOME /usr/lib/jvm/java
 ---> Running in f19681365fe5
 ---> fff2c21b0a71
Removing intermediate container f19681365fe5
Step 11 : ENV WILDFLY_VERSION 8.2.0.Final
 ---> Running in cc9d42ece5c1
 ---> b7b7ca7a9172
Removing intermediate container cc9d42ece5c1
Step 12 : RUN cd $HOME && curl -O http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.zip && unzip wildfly-$WILDFLY_VERSION.zip && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly && rm wildfly-$WILDFLY_VERSION.zip
 ---> Running in 28e92a1b304f
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  126M  100  126M    0     0   813k      0  0:02:38  0:02:38 --:--:--  644k
Archive:  wildfly-8.2.0.Final.zip
   creating: wildfly-8.2.0.Final/
   creating: wildfly-8.2.0.Final/.installation/
   creating: wildfly-8.2.0.Final/appclient/
   creating: wildfly-8.2.0.Final/appclient/configuration/
   creating: wildfly-8.2.0.Final/bin/

. . .

  inflating: wildfly-8.2.0.Final/domain/configuration/application-users.properties  
  inflating: wildfly-8.2.0.Final/domain/configuration/mgmt-users.properties  
  inflating: wildfly-8.2.0.Final/standalone/configuration/application-users.properties  
  inflating: wildfly-8.2.0.Final/standalone/configuration/mgmt-users.properties  
   creating: wildfly-8.2.0.Final/domain/tmp/auth/
   creating: wildfly-8.2.0.Final/standalone/tmp/auth/
 ---> a1bc79a43c77
Removing intermediate container 28e92a1b304f
Step 13 : ENV JBOSS_HOME /opt/jboss/wildfly
 ---> Running in e3c995170046
 ---> d46fdd618d55
Removing intermediate container e3c995170046
Step 14 : EXPOSE 8080 9990
 ---> Running in d55d6a6f43cf
 ---> 6c17e2cefecf
Removing intermediate container d55d6a6f43cf
Step 15 : CMD /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0
 ---> Running in 76e2630d16f5
 ---> 97c8780a7d6a
Removing intermediate container 76e2630d16f5
Successfully built 97c8780a7d6a

The list of Docker images can now be seen as:

wildfly-centos> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
wildfly-centos      latest              97c8780a7d6a        58 seconds ago      619.6 MB
centos              latest              ae0c2d0bdc10        2 weeks ago         224 MB

The total image size is 619.6 MB. The official WildFly Docker image can be installed as shown:

wildfly-centos> docker pull jboss/wildfly
Pulling repository jboss/wildfly
365390553f92: Download complete 
511136ea3c5a: Download complete 
782cf93a8f16: Download complete 
7d3f07f8de5f: Download complete 
1ef0a50fe8b1: Download complete 
20a1abe1d9bf: Download complete 
cd5bb934bb67: Download complete 
379edb00ab07: Download complete 
4d37cbbfc67d: Download complete 
2ea8562cac7c: Download complete 
7759146eab1a: Download complete 
b17a20d6f5f8: Download complete 
e02bdb6c4ed5: Download complete 
72d585299bb5: Download complete 
90832e1f0bb9: Download complete 
59ec65b61fba: Download complete 
57ada25ecdd0: Download complete 
184d6d02f340: Download complete 
d7fccab36b8f: Download complete 
Status: Downloaded newer image for jboss/wildfly:latest

And the complete list of Docker images can again be seen as:

wildfly-centos> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
wildfly-centos      latest              97c8780a7d6a        12 minutes ago      619.6 MB
centos              latest              ae0c2d0bdc10        2 weeks ago         224 MB
jboss/wildfly       latest              365390553f92        4 weeks ago         948.7 MB

The image size in this case is 948.7 MB. A detailed understanding of this image is created was explained earlier in this blog.

Ubuntu-based WildFly image can be built and installed as shown below. Note this command is given from the “wildfly-ubuntu” directory of github.com/arun-gupta/docker-images/. And so the Dockerfile is at github.com/arun-gupta/docker-images/blob/master/wildfly-ubuntu/Dockerfile.

wildfly-ubuntu> docker build -t wildfly-ubuntu .
Sending build context to Docker daemon 4.096 kB
Sending build context to Docker daemon 
Step 0 : FROM ubuntu
ubuntu:latest: The image you are pulling has been verified
d497ad3926c8: Pull complete 
ccb62158e970: Pull complete 
e791be0477f2: Pull complete 
3680052c0f5c: Pull complete 
22093c35d77b: Pull complete 
5506de2b643b: Pull complete 
511136ea3c5a: Already exists 
Status: Downloaded newer image for ubuntu:latest
 ---> 5506de2b643b
Step 1 : MAINTAINER Arun Gupta <[email protected]>
 ---> Running in cc444b436b26
 ---> 9df66d33d676
Removing intermediate container cc444b436b26
Step 2 : RUN apt-get update
 ---> Running in 3dc63c0f708a
Ign http://archive.ubuntu.com trusty InRelease
Ign http://archive.ubuntu.com trusty-updates InRelease
Ign http://archive.ubuntu.com trusty-security InRelease
Ign http://archive.ubuntu.com trusty-proposed InRelease
Get:1 http://archive.ubuntu.com trusty Release.gpg [933 B]
Get:2 http://archive.ubuntu.com trusty-updates Release.gpg [933 B]
Get:3 http://archive.ubuntu.com trusty-security Release.gpg [933 B]
Get:4 http://archive.ubuntu.com trusty-proposed Release.gpg [933 B]
Get:5 http://archive.ubuntu.com trusty Release [58.5 kB]
Get:6 http://archive.ubuntu.com trusty-updates Release [62.0 kB]
Get:7 http://archive.ubuntu.com trusty-security Release [62.0 kB]
Get:8 http://archive.ubuntu.com trusty-proposed Release [209 kB]
Get:9 http://archive.ubuntu.com trusty/main Sources [1335 kB]
Get:10 http://archive.ubuntu.com trusty/restricted Sources [5335 B]
Get:11 http://archive.ubuntu.com trusty/universe Sources [7926 kB]
Get:12 http://archive.ubuntu.com trusty/main amd64 Packages [1743 kB]
Get:13 http://archive.ubuntu.com trusty/restricted amd64 Packages [16.0 kB]
Get:14 http://archive.ubuntu.com trusty/universe amd64 Packages [7589 kB]
Get:15 http://archive.ubuntu.com trusty-updates/main Sources [179 kB]
Get:16 http://archive.ubuntu.com trusty-updates/restricted Sources [1250 B]
Get:17 http://archive.ubuntu.com trusty-updates/universe Sources [114 kB]
Get:18 http://archive.ubuntu.com trusty-updates/main amd64 Packages [465 kB]
Get:19 http://archive.ubuntu.com trusty-updates/restricted amd64 Packages [6341 B]
Get:20 http://archive.ubuntu.com trusty-updates/universe amd64 Packages [286 kB]
Get:21 http://archive.ubuntu.com trusty-security/main Sources [62.7 kB]
Get:22 http://archive.ubuntu.com trusty-security/restricted Sources [40 B]
Get:23 http://archive.ubuntu.com trusty-security/universe Sources [19.1 kB]
Get:24 http://archive.ubuntu.com trusty-security/main amd64 Packages [205 kB]
Get:25 http://archive.ubuntu.com trusty-security/restricted amd64 Packages [40 B]
Get:26 http://archive.ubuntu.com trusty-security/universe amd64 Packages [93.4 kB]
Get:27 http://archive.ubuntu.com trusty-proposed/main amd64 Packages [193 kB]
Get:28 http://archive.ubuntu.com trusty-proposed/restricted amd64 Packages [40 B]
Fetched 20.6 MB in 43s (469 kB/s)
Reading package lists...
 ---> 7fcaaf17b124
Removing intermediate container 3dc63c0f708a
Step 3 : RUN apt-get -y install xmlstarlet bsdtar unzip curl
 ---> Running in 81613b0e3b71
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  ca-certificates krb5-locales libarchive13 libasn1-8-heimdal libcurl3
  libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal

. . .

Updating certificates in /etc/ssl/certs... 164 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.
Processing triggers for sgml-base (1.26+nmu4ubuntu1) ...
 ---> 0d897d545547
Removing intermediate container 81613b0e3b71
Step 4 : RUN groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss
 ---> Running in bf31e0e1f448
 ---> 7494e71043c0
Removing intermediate container bf31e0e1f448
Step 5 : WORKDIR /opt/jboss
 ---> Running in 1ac355c74395
 ---> abbbb6aa6b71
Removing intermediate container 1ac355c74395
Step 6 : USER jboss
 ---> Running in a656007f6e6b
 ---> 657671b82d0f
Removing intermediate container a656007f6e6b
Step 7 : USER root
 ---> Running in f53138927d04
 ---> d3bd53152a51
Removing intermediate container f53138927d04
Step 8 : RUN apt-get -y install openjdk-7-jdk
 ---> Running in 1076b257c6f6
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  acl at-spi2-core ca-certificates ca-certificates-java colord cpp cpp-4.8
  dbus dbus-x11 dconf-gsettings-backend dconf-service desktop-file-utils

. . .

Adding debian:Wells_Fargo_Root_CA.pem
Adding debian:XRamp_Global_CA_Root.pem
Adding debian:certSIGN_ROOT_CA.pem
Adding debian:ePKI_Root_Certification_Authority.pem
Adding debian:thawte_Primary_Root_CA.pem
Adding debian:thawte_Primary_Root_CA_-_G2.pem
Adding debian:thawte_Primary_Root_CA_-_G3.pem
Adding debian:spi-cacert-2008.pem
done.
done.
 ---> 558f23c93a8c
Removing intermediate container 1076b257c6f6
Step 9 : USER jboss
 ---> Running in 9d6955bcd19f
 ---> 7f16c426ccaf
Removing intermediate container 9d6955bcd19f
Step 10 : ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
 ---> Running in 66f22bd0de95
 ---> 6304f386c946
Removing intermediate container 66f22bd0de95
Step 11 : ENV WILDFLY_VERSION 8.2.0.Final
 ---> Running in 784e1533fa09
 ---> 1a5e1aeadc85
Removing intermediate container 784e1533fa09
Step 12 : RUN cd $HOME && curl -O http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.zip && unzip wildfly-$WILDFLY_VERSION.zip && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly && rm wildfly-$WILDFLY_VERSION.zip
 ---> Running in c7d808526af6
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  126M  100  126M    0     0   993k      0  0:02:09  0:02:09 --:--:--  870k
Archive:  wildfly-8.2.0.Final.zip
   creating: wildfly-8.2.0.Final/

. . .

  inflating: wildfly-8.2.0.Final/standalone/configuration/mgmt-users.properties  
   creating: wildfly-8.2.0.Final/domain/tmp/auth/
   creating: wildfly-8.2.0.Final/standalone/tmp/auth/
 ---> 551e8b1db275
Removing intermediate container c7d808526af6
Step 13 : ENV JBOSS_HOME /opt/jboss/wildfly
 ---> Running in 7709c6f468ef
 ---> 0cec4b9ccd6b
Removing intermediate container 7709c6f468ef
Step 14 : EXPOSE 8080 9990
 ---> Running in dd053271b09e
 ---> 0281986b0ed8
Removing intermediate container dd053271b09e
Step 15 : CMD /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0
 ---> Running in fb29091de599
 ---> 6a1c4acf3f78
Removing intermediate container fb29091de599
Successfully built 6a1c4acf3f78

The list of Docker images can once again be seen as:

wildfly-ubuntu> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
wildfly-ubuntu      latest              6a1c4acf3f78        5 minutes ago       749.5 MB
<none>              <none>              1a5e1aeadc85        13 minutes ago      607.7 MB
wildfly-centos      latest              97c8780a7d6a        About an hour ago   619.6 MB
centos              latest              ae0c2d0bdc10        2 weeks ago         224 MB
jboss/wildfly       latest              365390553f92        4 weeks ago         948.7 MB
ubuntu              latest              5506de2b643b        4 weeks ago         199.3 MB

Docker image can run with docker run command. Some other related commands are:

  • docker ps: Lists containers
  • docker stop <id>: Stops the container with the given <id>

Run CentOS image as shown below. Specifying -i option will make it interactive and -t option allocates a pseudo-TTY. And port 8080 from the container is made accessible on port 80 of the container.

~> docker run -i -t -p 80:8080 wildfly-centos
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

22:20:52,769 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
22:20:53,038 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
22:20:53,120 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.0.Final "Tweek" starting
22:20:54,176 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
22:20:54,197 INFO  [org.xnio] (MSC service thread 1-10) XNIO version 3.3.0.Final
22:20:54,206 INFO  [org.xnio.nio] (MSC service thread 1-10) XNIO NIO Implementation Version 3.3.0.Final
22:20:54,239 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
22:20:54,265 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
22:20:54,302 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem
22:20:54,314 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
22:20:54,345 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]
22:20:54,363 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
22:20:54,374 INFO  [org.jboss.as.security] (MSC service thread 1-8) JBAS013170: Current PicketBox version=4.0.21.Final
22:20:54,419 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
22:20:54,486 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-7) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)
22:20:54,573 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) JBAS017502: Undertow 1.1.0.Final starting
22:20:54,579 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.0.Final starting
22:20:54,586 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
22:20:54,644 INFO  [org.jboss.remoting] (MSC service thread 1-10) JBoss Remoting version 4.0.6.Final
22:20:54,658 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) JBAS010417: Started Driver service with driver-name = h2
22:20:54,763 INFO  [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
22:20:54,761 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-16) JBAS015400: Bound mail session [java:jboss/mail/Default]
22:20:56,387 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /opt/jboss/wildfly/welcome-content
22:20:56,422 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-10) JBAS017525: Started server default-server.
22:20:56,544 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017531: Host default-host starting
22:20:56,712 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-10) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:8080
22:20:56,975 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-14) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
22:20:56,976 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-15) JBAS015012: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
22:20:57,172 INFO  [org.jboss.ws.common.management] (MSC service thread 1-10) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final
22:20:57,239 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
22:20:57,240 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
22:20:57,241 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 4836ms - Started 184 of 234 services (82 services are lazy, passive or on-demand)

In a different shell, get the container’s IP address as:

~> boot2docker ip

The VM's Host only interface IP address is: 192.168.59.103

And then access WildFly at http://192.168.59.103.

Similarly, running the WildFly Ubuntu image shows:

wildfly-ubuntu> docker run -i -t -p 80:8080 wildfly-ubuntu
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

  JAVA: /usr/lib/jvm/java-7-openjdk-amd64/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

22:34:07,612 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
22:34:07,911 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
22:34:07,996 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.0.Final "Tweek" starting
22:34:09,076 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
22:34:09,097 INFO  [org.xnio] (MSC service thread 1-9) XNIO version 3.3.0.Final
22:34:09,106 INFO  [org.xnio.nio] (MSC service thread 1-9) XNIO NIO Implementation Version 3.3.0.Final
22:34:09,136 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
22:34:09,170 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem
22:34:09,180 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
22:34:09,191 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]
22:34:09,207 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
22:34:09,212 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013170: Current PicketBox version=4.0.21.Final
22:34:09,230 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
22:34:09,317 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017502: Undertow 1.1.0.Final starting
22:34:09,317 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.0.Final starting
22:34:09,323 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
22:34:09,413 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-15) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)
22:34:09,617 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
22:34:09,658 INFO  [org.jboss.as.naming] (MSC service thread 1-10) JBAS011802: Starting Naming Service
22:34:09,674 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session [java:jboss/mail/Default]
22:34:09,692 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-12) JBAS010417: Started Driver service with driver-name = h2
22:34:09,693 INFO  [org.jboss.remoting] (MSC service thread 1-9) JBoss Remoting version 4.0.6.Final
22:34:11,117 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /opt/jboss/wildfly/welcome-content
22:34:11,134 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017525: Started server default-server.
22:34:11,206 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017531: Host default-host starting
22:34:11,377 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:8080
22:34:11,576 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
22:34:11,627 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
22:34:11,847 INFO  [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final
22:34:11,911 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
22:34:11,912 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
22:34:11,912 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 4762ms - Started 184 of 234 services (82 services are lazy, passive or on-demand)

You can login to the host VM as shown:

boot2docker ssh

Different layers of the image are stored in /var/lib/docker directory as shown:

docker-images> boot2docker ssh
                        ##        .
                  ## ## ##       ==
               ## ## ## ##      ===
           /""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
           \______ o          __/
             \    \        __/
              \____\______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.3.2, build master : 495c19a - Mon Nov 24 20:40:58 UTC 2014
Docker version 1.3.2, build 39fa2fa
docker@boot2docker:~$ cd /var/lib/docker/
docker@boot2docker:/mnt/sda1/var/lib/docker$ ls -la
total 64
drwxr-xr-x   10 root     root          4096 Nov 24 23:33 ./
drwxr-xr-x    4 root     root          4096 Nov 24 19:15 ../
drwxr-xr-x    5 root     root          4096 Nov 24 19:16 aufs/
drwx------   17 root     root          4096 Nov 24 23:33 containers/
drwx------    3 root     root          4096 Nov 24 19:16 execdriver/
drwx------   84 root     root         12288 Nov 24 23:28 graph/
drwx------    2 root     root          4096 Nov 25 14:50 init/
-rw-r--r--    1 root     root         11264 Nov 24 23:33 linkgraph.db
-rw-------    1 root     root           565 Nov 24 23:28 repositories-aufs
drwx------    2 root     root          4096 Nov 24 23:28 tmp/
drwx------    2 root     root          4096 Nov 24 19:21 trust/
drwx------    2 root     root          4096 Nov 24 19:16 volumes/

VM image on Mac OSX is stored in ~/VirtualBox VMs/boot2docker-vm directory. This directory can grow up rather quickly if the intermediate containers are not removed. boot2docker-vm.vmdk on my machine is ~5GB for these different images.

You can reset it by running the following commands (WARNING: This will destroy all images you’ve downloaded and built so far):

boot2docker down
boot2docker destroy
boot2docker init
boot2docker up

Containers, as you can imagine, have a memory foot print.

More Docker goodness is coming in subsequent blogs!

Deployment Pipeline for Java EE 7 with WildFly, Arquillian, Jenkins, and OpenShift (Tech Tip #56)

Tech Tip #54 showed how to Arquillianate (Arquillianize ?) an existing Java EE project and run those tests in remote mode where WildFly is running on a known host and port. Tech Tip #55 showed how to run those tests when WildFly is running in OpenShift. Both of these tips used Maven profiles to separate the appropriate Arquillian dependencies in “pom.xml” and <container> configuration in “arquillian.xml” to define where WildFy is running and how to connect to it.

This tip will show how to configure Jenkins in OpenShift and invoke these tests from Jenkins. This will create deployment pipeline for Java EE.

Lets see it in action first!

Configuration required to connect from Jenkins on OpenShift to a WildFly instance on OpenShift is similar to that required for  connecting from local machine to WildFly on OpenShift. This configuration is specified in “arquillian.xml” and we can specify some parameters which can then be defined in Jenkins.

On a high level, here is what we’ll do:

  • Use the code created in Tech Tip #54 and #55 and add configuration for Arquillian/Jenkins/OpenShift
  • Enable Jenkins
  • Create a new WildFly Test instance
  • Configure Jenkins to run tests on the Test instance
  • Push the application to Production only if tests pass on Test instance

Lets get started!

  1. Remove the existing boilerplate source code, only the src directory, from the WildFly git repo created in Tech Tip #55.
    mywildfly> git rm -rf src/ pom.xml
    rm 'pom.xml'
    rm 'src/main/java/.gitkeep'
    rm 'src/main/resources/.gitkeep'
    rm 'src/main/webapp/WEB-INF/web.xml'
    rm 'src/main/webapp/images/jbosscorp_logo.png'
    rm 'src/main/webapp/index.html'
    rm 'src/main/webapp/snoop.jsp'
    mywildfly> git commit . -m"removing source and pom"
    [master 564b275] removing source and pom
     7 files changed, 647 deletions(-)
     delete mode 100644 pom.xml
     delete mode 100644 src/main/java/.gitkeep
     delete mode 100644 src/main/resources/.gitkeep
     delete mode 100644 src/main/webapp/WEB-INF/web.xml
     delete mode 100644 src/main/webapp/images/jbosscorp_logo.png
     delete mode 100644 src/main/webapp/index.html
     delete mode 100644 src/main/webapp/snoop.jsp
  2. Set a new remote to javaee7-continuous-delivery repository:
    mywildfly> git remote add javaee7 https://github.com/arun-gupta/javaee7-continuous-delivery.git
    mywildfly> git remote -v
    javaee7 https://github.com/arun-gupta/javaee7-continuous-delivery.git (fetch)
    javaee7 https://github.com/arun-gupta/javaee7-continuous-delivery.git (push)
    origin  ssh://[email protected]/~/git/mywildfly.git/ (fetch)
    origin  ssh://[email protected]/~/git/mywildfly.git/ (push)
  3. Pull the code from new remote:
    mywildfly> git pull javaee7 master
    warning: no common commits
    remote: Counting objects: 62, done.
    remote: Compressing objects: 100% (45/45), done.
    remote: Total 62 (delta 14), reused 53 (delta 5)
    Unpacking objects: 100% (62/62), done.
    From https://github.com/arun-gupta/javaee7-continuous-delivery
     * branch            master     -> FETCH_HEAD
     * [new branch]      master     -> javaee7/master
    Merge made by the 'recursive' strategy.
     .gitignore                                           |   6 +++
     README.asciidoc                                      |  15 ++++++
     pom.xml                                              | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     src/main/java/org/javaee7/sample/MyApplication.java  |   9 ++++
     src/main/java/org/javaee7/sample/Person.java         |  31 ++++++++++++
     src/main/java/org/javaee7/sample/PersonDatabase.java |  39 ++++++++++++++
     src/main/java/org/javaee7/sample/PersonResource.java |  29 +++++++++++
     src/main/webapp/index.jsp                            |  13 +++++
     src/test/java/org/javaee7/sample/PersonTest.java     |  77 ++++++++++++++++++++++++++++
     src/test/resources/arquillian.xml                    |  26 ++++++++++
     10 files changed, 442 insertions(+)
     create mode 100644 .gitignore
     create mode 100644 README.asciidoc
     create mode 100644 pom.xml
     create mode 100644 src/main/java/org/javaee7/sample/MyApplication.java
     create mode 100644 src/main/java/org/javaee7/sample/Person.java
     create mode 100644 src/main/java/org/javaee7/sample/PersonDatabase.java
     create mode 100644 src/main/java/org/javaee7/sample/PersonResource.java
     create mode 100644 src/main/webapp/index.jsp
     create mode 100644 src/test/java/org/javaee7/sample/PersonTest.java
     create mode 100644 src/test/resources/arquillian.xml

    This will bring all the source code, include our REST endpoints, web pages, tests, updated “pom.xml” and “arquillian.xml”. The updated “pom.xml” has two new profiles.

    <profile>
     <id>openshift</id>
     <build>
        <plugins>
          <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <outputDirectory>deployments</outputDirectory>
                          <warName>ROOT</warName>
                </configuration>
            </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
        <id>jenkins-openshift</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.14.1</version>
                    <configuration>
                        <systemPropertyVariables>
                            <arquillian.launch>jenkins-openshift</arquillian.launch>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-openshift</artifactId>
                <version>1.0.0.Final-SNAPSHOT</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>

    Few points to observe here:

    1. “openshift” profile is used when building an application on OpenShift. This is where the application’s WAR file is created and deployed to WildFly.
    2. A new profile “jenkins-openshift” is added that will be used by the Jenkins instance (to be enabled shortly) in OpenShift to run tests.
    3. “arquillian-openshift” dependency is the same as used in Tech Tip #55 and allows to run Arquillian tests on a WildFly instance on OpenShift.
    4. This profile refers to “jenkins-openshift” container configuration that will be defined in “arquillian.xml”.

    Updated “src/test/resources/arquillian.xml” has the following container:

    <container qualifier="jenkins-openshift">
        <configuration>
            <property name="namespace">${env.ARQ_DOMAIN}</property>
            <property name="application">${env.ARQ_APPLICATION}</property>
            <property name="libraDomain">rhcloud.com</property>
            <property name="sshUserName">${env.ARQ_SSH_USER_NAME}</property>
            <property name="login">[email protected]</property>
            <property name="deploymentTimeoutInSeconds">300</property>
            <property name="disableStrictHostChecking">true</property> 
        </configuration>
    </container>
    

    This container configuration is similar to the one that was added in Tech Tip #55. The only difference here is that the domain name, application name, and the SSH user name are parametrized. The value of these properties is defined in the configuration of Jenkins instance and allows to run the test against a separate test node.

  4. Two more things need to be done before changes can be pushed to the remote repository. First is to create a WildFly Test instance which can be used to run the tests. This can be easily done as shown:
    workspaces> rhc app-create mywildflytest jboss-wildfly-8
    Application Options
    -------------------
    Domain:     milestogo
    Cartridges: jboss-wildfly-8
    Gear Size:  default
    Scaling:    no
    
    Creating application 'mywildflytest' ... Artifacts deployed: ./ROOT.war
    done
    
      WildFly 8 administrator added.  Please make note of these credentials:
    
       Username: adminITJt7Yh
       Password: yXP2mUd1w4_8
       
       run 'rhc port-forward mywildflytest' to access the web admin area on port 9990.
    
    Waiting for your DNS name to be available ... done
    
    Cloning into 'mywildflytest'...
    Warning: Permanently added the RSA host key for IP address '54.205.69.88' to the list of known hosts.
    
    Your application 'mywildflytest' is now available.
    
      URL:        http://mywildflytest-milestogo.rhcloud.com/
      SSH to:     [email protected]
      Git remote: ssh://[email protected]/~/git/mywildflytest.git/
      Cloned to:  /Users/arungupta/workspaces/javaee7/mywildflytest
    
    Run 'rhc show-app mywildflytest' for more details about your app.

    Note the domain here is milestogo, application name is mywildflytest, and SSH user name is 546e3743ecb8d49ca9000014. These will be passed to Arquillian for running the tests.

  5. Second is to enable and configure Jenkins.In your OpenShift Console, pick the “mywildfly” application and click on “Enable Jenkins” link as shown below:techtip56-enable-jenkinsRemember this is not your Test instance because all the source code lives on the instance created earlier.Provide the appropriate name, e.g. jenkins-milestogo.rhcloud.com in my case, and click on “Add Jenkins” button. This will provision a Jenkins instance, if not already there and also configure the project with a script to build and deploy the application. Note down the name and password credentials.
  6. Use the credentials to login to your Jenkins instance.Select the appropriate build, “mywildfly-build” in this case. Scroll down to the “Build” section and add the following script right after “# Run tests here” in the Execute Shell:
    export ARQ_DOMAIN=milestogo
    export ARQ_SSH_USER_NAME=546e3743ecb8d49ca9000014
    export ARQ_APPLICATION=mywildflytest
    mvn test -Pjenkins-openshift

    Click on “Save” to save the configuration. This will allow to run the Arquillian tests on the Test instance. If the tests pass then the app is deployed. If the tests fail, then none of the steps after that step are executed and so the app is not deployed.

  7. Lets push the changes to remote repo now:
    mywildfly> git push
    Counting objects: 68, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (49/49), done.
    Writing objects: 100% (61/61), 8.85 KiB | 0 bytes/s, done.
    Total 61 (delta 14), reused 0 (delta 0)
    remote: Executing Jenkins build.
    remote: 
    remote: You can track your build at https://jenkins-milestogo.rhcloud.com/job/mywildfly-build
    remote: 
    remote: Waiting for build to schedule............................................................................................Done
    remote: Waiting for job to complete................................................................................................................................................................................................................................................................................................................................................................................................Done
    remote: SUCCESS
    remote: New build has been deployed.
    remote: -------------------------
    remote: Git Post-Receive Result: success
    remote: Deployment completed with status: success
    To ssh://[email protected]/~/git/mywildfly.git/
       e8f6c61..e9ad206  master -> master

    The number of dots indicate the wait for a particular task and will most likely vary for different runs.  And Jenkins console (jenkins-milestogo.rhcloud.com/job/mywildfly-build/1/console) shows the output as:

    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running org.javaee7.sample.PersonTest
    Nov 20, 2014 2:54:56 PM org.jboss.arquillian.container.openshift.OpenShiftContainer start
    INFO: Preparing Arquillian OpenShift container at http://mywildflytest-milestogo.rhcloud.com
    Nov 20, 2014 2:55:48 PM org.jboss.arquillian.container.openshift.OpenShiftRepository push
    INFO: Pushed to the remote repository ssh://[email protected]/~/git/mywildflytest.git/
    Nov 20, 2014 2:56:37 PM org.jboss.arquillian.container.openshift.OpenShiftRepository push
    INFO: Pushed to the remote repository ssh://[email protected]/~/git/mywildflytest.git/
    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 103.056 sec
    Nov 20, 2014 2:56:37 PM org.jboss.arquillian.container.openshift.OpenShiftContainer stop
    INFO: Shutting down Arquillian OpenShift container at http://mywildflytest-milestogo.rhcloud.com
    Results :
    
    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
    
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 3:13.069s
    [INFO] Finished at: Thu Nov 20 14:57:34 EST 2014
    [INFO] Final Memory: 10M/101M
    [INFO] ------------------------------------------------------------------------
    + /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh [email protected] 'gear stop --conditional'
    Warning: Permanently added 'mywildfly-milestogo.rhcloud.com,10.5.171.43' (RSA) to the list of known hosts.
    Stopping gear...
    Stopping wildfly cart
    Sending SIGTERM to wildfly:418673 ...
    + rsync --delete-after -azO -e /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh /var/lib/openshift/546e46304382ec3f29000012//.m2/ '[email protected]:~/.m2/'
    Warning: Permanently added 'mywildfly-milestogo.rhcloud.com,10.5.171.43' (RSA) to the list of known hosts.
    + rsync --delete-after -azO -e /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh /var/lib/openshift/546e46304382ec3f29000012/app-root/runtime/repo/deployments/ '[email protected]:${OPENSHIFT_REPO_DIR}deployments/'
    Warning: Permanently added 'mywildfly-milestogo.rhcloud.com,10.5.171.43' (RSA) to the list of known hosts.
    + rsync --delete-after -azO -e /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh /var/lib/openshift/546e46304382ec3f29000012/app-root/runtime/repo/.openshift/ '[email protected]:${OPENSHIFT_REPO_DIR}.openshift/'
    Warning: Permanently added 'mywildfly-milestogo.rhcloud.com,10.5.171.43' (RSA) to the list of known hosts.
    + /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh [email protected] 'gear remotedeploy'
    Warning: Permanently added 'mywildfly-milestogo.rhcloud.com,10.5.171.43' (RSA) to the list of known hosts.
    Preparing build for deployment
    Deployment id is dff28e58
    Activating deployment
    Deploying WildFly
    Starting wildfly cart
    Found 127.12.255.129:8080 listening port
    Found 127.12.255.129:9990 listening port
    /var/lib/openshift/546e36e5e0b8cd4e2a000007/wildfly/standalone/deployments /var/lib/openshift/546e36e5e0b8cd4e2a000007/wildfly
    /var/lib/openshift/546e36e5e0b8cd4e2a000007/wildfly
    CLIENT_MESSAGE: Artifacts deployed: ./ROOT.war
    Archiving artifacts
    Finished: SUCCESS

    Log files for Jenkins can be viewed as shown:

    Nov 20, 2014 2:51:11 PM hudson.plugins.openshift.OpenShiftCloud provision
    INFO: Provisioning new node for workload = 2 and label = mywildfly-build in domain milestogo
    Nov 20, 2014 2:51:11 PM hudson.plugins.openshift.OpenShiftCloud getOpenShiftConnection
    INFO: Initiating Java Client Service - Configured for OpenShift Server https://openshift.redhat.com
    Nov 20, 2014 2:51:11 PM com.openshift.internal.client.RestService request
    INFO: Requesting GET with protocol 1.2 on https://openshift.redhat.com/broker/rest/api
    Nov 20, 2014 2:51:11 PM com.openshift.internal.client.RestService request
    INFO: Requesting GET with protocol 1.2 on https://openshift.redhat.com/broker/rest/user
    Nov 20, 2014 2:51:11 PM com.openshift.internal.client.RestService request
    
    . . .
    
    INFO: Checking availability of computer hudson.plugins.openshift.OpenShiftSlave@8ce21115
    Nov 20, 2014 2:53:35 PM com.openshift.internal.client.RestService request
    INFO: Requesting GET with protocol 1.2 on https://openshift.redhat.com/broker/rest/domain/milestogo/application/mywildflybldr/gear_groups
    Nov 20, 2014 2:53:35 PM hudson.plugins.openshift.OpenShiftComputerLauncher launch
    INFO: Checking SSH access to application mywildflybldr-milestogo.rhcloud.com
    Nov 20, 2014 2:53:35 PM hudson.plugins.openshift.OpenShiftComputerLauncher launch
    INFO: Connecting via SSH '546e46304382ec3f29000012' 'mywildflybldr-milestogo.rhcloud.com' '/var/lib/openshift/546e393e5973ca0492000070/app-root/data/.ssh/jenkins_id_rsa'
    Nov 20, 2014 2:53:35 PM hudson.slaves.NodeProvisioner update
    INFO: mywildfly-build provisioningE successfully completed. We have now 2 computer(s)
    Nov 20, 2014 2:53:35 PM hudson.plugins.openshift.OpenShiftComputerLauncher launch
    INFO: Connected via SSH.
    Nov 20, 2014 2:53:35 PM hudson.plugins.openshift.OpenShiftComputerLauncher launch
    INFO: Exec mkdir -p $OPENSHIFT_DATA_DIR/jenkins && cd $OPENSHIFT_DATA_DIR/jenkins && rm -f slave.jar && wget -q --no-check-certificate https://jenkins-milestogo.rhcloud.com/jnlpJars/slave.jar
    Nov 20, 2014 2:53:42 PM hudson.plugins.openshift.OpenShiftComputerLauncher launch
    INFO: Slave connected.
    Nov 20, 2014 2:58:24 PM hudson.model.Run execute
    INFO: mywildfly-build #1 main build action completed: SUCCESS

    This shows the application was successfully deployed at mywildfly-milestogo.rhcloud.com/index.jsp and looks like as shown:

    techtip56-mywildfly-output-tests-passing

Now change “src/main/webapp/index.jsp” to show a different heading. And change  “src/test/java/org/javaee7/sample/PersonTest.java” to make one of the tests fail. Doing “git commit” and “git push” shows the following results on command line:

mywildfly> git commit . -m"breaking the test"
[master ff2de09] breaking the test
 2 files changed, 2 insertions(+), 2 deletions(-)
mywildfly> git push
Counting objects: 23, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (12/12), 771 bytes | 0 bytes/s, done.
Total 12 (delta 5), reused 0 (delta 0)
remote: Executing Jenkins build.
remote: 
remote: You can track your build at https://jenkins-milestogo.rhcloud.com/job/mywildfly-build
remote: 
remote: Waiting for build to schedule.......Done
remote: Waiting for job to complete.....................................................................................................................................................................Done
remote: FAILED
remote: !!!!!!!!
remote: Deployment Halted!
remote: If the build failed before the deploy step, your previous
remote: build is still running.  Otherwise, your application may be
remote: partially deployed or inaccessible.
remote: Fix the build and try again.
remote: !!!!!!!!
remote: An error occurred executing 'gear postreceive' (exit code: 1)
remote: Error message: CLIENT_ERROR: Failed to execute: 'control post-receive' for /var/lib/openshift/546e36e5e0b8cd4e2a000007/jenkins-client
remote: 
remote: For more details about the problem, try running the command again with the '--trace' option.
To ssh://[email protected]/~/git/mywildfly.git/
   d618fad..ff2de09  master -> master

The key statement to note is that deployment is halted after the tests are failing. And you can verify this by revisiting mywildfly-milestogo.rhcloud.com/index.jsp and check that the updated “index.jsp” is not visible.

In short, tests pass, website is updated. And tests fail, the website is not updated. So you’ve built a simple deployment pipeline for Java EE 7 using WildFly, OpenShift, Arquillian, and Jenkins!

Continuous Deployment with Java EE 7, WildFly, and Docker – (Hanginar #1)

This blog is starting a new hanginar (G+ hangout + webinar) series that will highlight solutions, frameworks, application servers, tooling, deployment, and more content focused on Java EE. These are not the usual conference-style monologue presentations, but are interactive hackathons where real working stuff is shown, and is mostly code-driven. Think of this as a mix of, and inspired by, Nighthacking (@_nighthacking), Virtual JUG (@virtualjug), and virtual JBUG (@vjbug) but focussing purely on Java EE technology.

There are so many cool things happening in the Java EE platform and ecosystem around it, and they need to be shared with the broader community, more importantly at a location where people can go back again and again. Voxxed.com has graciously offered to host all the videos and be the central place for this content.

The first such webinar, with none other than Adam Bien (@adambien), in that series just went live. It discusses how to do Continuous Deployment with Java EE 7 and Docker. It will also show how to go from “git push” to production in less than a minute, including rebooting your Docker containers and restarting all your microservices.

A tentative list of speakers is identified at github.com/javaee-samples/webinars. Each speaker is assigned an issue which allows you to ask questions. Feel free to file an issue for any other speaker that should be on the list.

What would you like to see ? Spec leads ? App servers ? Why this over that ? Design patterns and anti-patterns ? Anonymous customer use cases ? What frequency would you like to see ? Use G+ hangout on air ?

As with any new effort, we’ll learn and evolve and see what makes best sense for the Java EE community.

So what’s the mantra ? Code is king, give some love to Java EE!

 

Arquillian tests on a WildFly instance hosted on OpenShift (Tech Tip #55)

Tech Tip #54 explained how to enable Arquillian for an existing Java EE project. In that tip, the tests were run against a locally installed WildFly server. Would the same adapter work if this WildFly instance was running on OpenShift ? No!

Because the security constraints and requirement of a PaaS, as opposed to a localhost, are different. Lets take a look at what’s required to run our tests in javaee7-continuous-delivery on a WildFly instance hosted on OpenShift.

Lets get started!

  1. As explained in Tech Tip #52, create a WildFly application on OpenShift as shown:
    workspaces> rhc app-create mywildfly jboss-wildfly-8
    Application Options
    -------------------
    Domain:     milestogo
    Cartridges: jboss-wildfly-8
    Gear Size:  default
    Scaling:    no
    
    Creating application 'mywildfly' ... Artifacts deployed: ./ROOT.war
    done
    
      WildFly 8 administrator added.  Please make note of these credentials:
    
       Username: adminMYtMTDb
       Password: tq1K-QYLFgBD
       
       run 'rhc port-forward mywildfly' to access the web admin area on port 9990.
    
    Waiting for your DNS name to be available ... done
    
    Cloning into 'mywildfly'...
    Warning: Permanently added the RSA host key for IP address '54.163.64.193' to the list of known hosts.
    
    Your application 'mywildfly' is now available.
    
      URL:        http://mywildfly-milestogo.rhcloud.com/
      SSH to:     [email protected]
      Git remote: ssh://[email protected]/~/git/mywildfly.git/
      Cloned to:  /Users/arungupta/workspaces/mywildfly
    
    Run 'rhc show-app mywildfly' for more details about your app.

    Note down the ssh user name from the log. This is the part before @ in the value corresponding to SSH to.

  2. Until FORGEPLUGINS-177 is resolved, we need to manually add maven profile and provide container configuration information in “arquillian.xml”. Add the following <profile> to “pom.xml”:
    <profile>
        <id>arquillian-wildfly-openshift</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.14.1</version>
                    <configuration>
                        <systemPropertyVariables>
                            <arquillian.launch>arquillian-wildfly-openshift</arquillian.launch>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-openshift</artifactId>
                <version>1.0.0.Final-SNAPSHOT</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>

    This is using arquillian-openshift container and referring to arquillian-wildfly-openshift configuration that will be matched with the appropriate container in “arquillian.xml”.

    So this is how the updated “arquillian.xml” look:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <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">
        <container qualifier="arquillian-wildfly-remote"/>
        <container qualifier="arquillian-wildfly-openshift">
            <configuration>
                <property name="namespace">milestogo</property>
                <property name="application">mywildfly</property>
                <property name="libraDomain">rhcloud.com</property>
                <property name="sshUserName">54699516ecb8d41cb8000016</property>
                <property name="login">[email protected]</property>
                <property name="deploymentTimeoutInSeconds">300</property>
                <property name="disableStrictHostChecking">true</property> 
            </configuration>
        </container>
    </arquillian>
    

    Note the new <container> with the qualifier arquillian-wildfly-openshift. It provides information about where the server is located and some other configuration properties. The sshUserName property value should be the same from the WildFly instance created earlier.

  3. That’s it, now you can run the test against the WildFly instance on OpenShift:
    javaee7-simple-sample> mvn test -Parquillian-wildfly-openshift
    [INFO] Scanning for projects...
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building helloworld 1.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 0 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloworld ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloworld ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 1 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ helloworld ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ helloworld ---
    [INFO] Surefire report directory: /Users/arungupta/workspaces/javaee7-simple-sample/target/surefire-reports
    
    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running org.javaee7.sample.PersonTest
    Nov 17, 2014 11:18:24 AM org.jboss.arquillian.container.openshift.OpenShiftContainer start
    INFO: Preparing Arquillian OpenShift container at http://mywildfly-milestogo.rhcloud.com
    Nov 17, 2014 11:19:19 AM org.jboss.arquillian.container.openshift.OpenShiftRepository push
    INFO: Pushed to the remote repository ssh://[email protected]/~/git/mywildfly.git/
    Nov 17, 2014 11:20:56 AM org.jboss.arquillian.container.openshift.OpenShiftRepository push
    INFO: Pushed to the remote repository ssh://[email protected]/~/git/mywildfly.git/
    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 152.653 sec
    Nov 17, 2014 11:20:56 AM org.jboss.arquillian.container.openshift.OpenShiftContainer stop
    INFO: Shutting down Arquillian OpenShift container at http://mywildfly-milestogo.rhcloud.com
    
    Results :
    
    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
    
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 05:46 min
    [INFO] Finished at: 2014-11-17T11:24:09+02:00
    [INFO] Final Memory: 12M/309M
    [INFO] ------------------------------------------------------------------------

The complete source code is available at github.com/arun-gupta/javaee7-continuous-delivery.

Enjoy!