Tuesday, November 1, 2016

Install Java EE7 application using JBoss Wildfly Docker image


Docker and WildFly Part 1 - Deployment via Docker volumes 

 
Docker and WildFly Part 2 - Deployment over management API


https://github.com/goldmann/wildfly-docker-deployment-example

Download JBoss Wildfly image
https://hub.docker.com/r/jboss/wildfly/


[dave@localhost wildfly]$ docker run -it jboss/wildfly
Unable to find image 'jboss/wildfly:latest' locally
latest: Pulling from jboss/wildfly

8d30e94188e7: Pull complete 
183bb107e46a: Pull complete 
9ea1527ac190: Pull complete 
d632efeddd98: Pull complete 
11af01a2d795: Pull complete 
Digest: sha256:2bed1e7a68245509de5837435b6250491efe61a86533f5ce6bf94927814076fb
Status: Downloaded newer image for jboss/wildfly:latest
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

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

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

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


Use port redirect to see Wildfly running in the browser

[dave@localhost wildfly]$ docker run -it -p 8080:8080 jboss/wildfly 

Wildfly home page
Add access to console using own Dockerfile

[dave@localhost wildfly]$ more Dockerfile 
FROM jboss/wildfly:latest

USER jboss
RUN /opt/jboss/wildfly/bin/add-user.sh admin MY_PASSWORD_TO_ACCESS --silent
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]


Build the Docker image

[dave@localhost wildfly]$ docker build --tag=wildfly-mgmt .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM jboss/wildfly:latest
 ---> 4c99bd2cd264
Step 2 : USER jboss
 ---> Running in de10054221e5
 ---> f3b3e54e823b
Removing intermediate container de10054221e5
Step 3 : RUN /opt/jboss/wildfly/bin/add-user.sh admin MY_PASSWORD_TO_ACCESS --silent
 ---> Running in 9af7cd245555
 ---> 5a29ccf7bef0
Removing intermediate container 9af7cd245555
Step 4 : CMD /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0
 ---> Running in 642784343b49
 ---> 3ea63bcef45a
Removing intermediate container 642784343b49
Successfully built 3ea63bcef45a


Start with port 8080 and 9990 redirected

[dave@localhost wildfly]$ docker run -it -p 8080:8080 -p 9990:9990  wildfly-mgmt

Check the console access via browser on 9990


Deploy Java EE7 app using Maven

Source code for the application GitHub https://github.com/dveselka/wildfly/tree/master/dave-java-ee7-wildfly-full

[dave@localhost dave-java-ee7-wildfly-full]$  mvn clean package wildfly:deploy
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] dave-java-ee7-wildfly-full
[INFO] dave-java-ee7-wildfly-full: EJB Module
[INFO] dave-java-ee7-wildfly-full: WAR Module
[INFO] dave-java-ee7-wildfly-full: EAR Module
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building dave-java-ee7-wildfly-full 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ dave-java-ee7-wildfly-full ---
[INFO] 
[INFO] >>> wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) > package @ dave-java-ee7-wildfly-full >>>
[INFO] 
[INFO] <<< wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) < package @ dave-java-ee7-wildfly-full <<<
[INFO] 
[INFO] --- wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) @ dave-java-ee7-wildfly-full ---

Deployment in Docker Widlfy

05:32:38,366 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 4639ms - Started 331 of 577 services (393 services are lazy, passive or on-demand)
05:43:49,778 INFO  [org.jboss.as.repository] (management-handler-thread - 1) WFLYDR0001: Content added at location /opt/jboss/wildfly/standalone/data/content/a1/58abbd7beeb79e23f10486bbefb72f55dc5368/content
05:43:49,861 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "dave-java-ee7-wildfly-full-ear.ear" (runtime-name: "dave-java-ee7-wildfly-full-ear.ear")
05:43:50,006 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0207: Starting subdeployment (runtime-name: "dave-java-ee7-wildfly-full-web.war")
05:43:50,006 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0207: Starting subdeployment (runtime-name: "dave-java-ee7-wildfly-full-ejb.jar")
05:43:50,168 WARN  [org.jboss.as.connector] (MSC service thread 1-1) WFLYJCA0091: -ds.xml file deployments are deprecated. Support may be removed in a future version.
05:43:50,620 INFO  [org.jboss.as.jpa] (MSC service thread 1-5) WFLYJPA0002: Read persistence.xml for primary
05:43:50,900 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) WFLYJCA0001: Bound data source [java:jboss/datasources/dave-java-ee7-wildfly-fullDS]
05:43:50,966 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 69) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'dave-java-ee7-wildfly-full-ear.ear/dave-java-ee7-wildfly-full-ejb.jar#primary'
05:43:50,977 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0003: Processing weld deployment dave-java-ee7-wildfly-full-ear.ear
05:43:51,095 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 69) HHH000204: Processing PersistenceUnitInfo [
    name: primary
    ...]
05:43:51,494 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-1) HV000001: Hibernate Validator 5.2.4.Final
05:43:51,653 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 69) HHH000412: Hibernate Core {5.0.10.Final}
05:43:51,655 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 69) HHH000206: hibernate.properties not found
05:43:51,664 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 69) HHH000021: Bytecode provider name : javassist
05:43:51,864 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 69) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
05:43:52,082 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0003: Processing weld deployment dave-java-ee7-wildfly-full-ejb.jar
05:43:52,090 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) WFLYWELD0003: Processing weld deployment dave-java-ee7-wildfly-full-web.war
05:43:52,120 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-1) WFLYEJB0473: JNDI bindings for session bean named 'MemberRegistration' in deployment unit 'subdeployment "dave-java-ee7-wildfly-full-ejb.jar" of deployment "dave-java-ee7-wildfly-full-ear.ear"' are as follows:

    java:global/dave-java-ee7-wildfly-full-ear/dave-java-ee7-wildfly-full-ejb/MemberRegistration!dave.service.MemberRegistration
    java:app/dave-java-ee7-wildfly-full-ejb/MemberRegistration!dave.service.MemberRegistration
    java:module/MemberRegistration!dave.service.MemberRegistration
    java:global/dave-java-ee7-wildfly-full-ear/dave-java-ee7-wildfly-full-ejb/MemberRegistration
    java:app/dave-java-ee7-wildfly-full-ejb/MemberRegistration
    java:module/MemberRegistration


Check the application in the browser

4 comments:

  1. Hi
    wondering if you could write a little more on this topic?
    I'd be very thankful if you could elaborate a little bit more. Appreciate it!
    Thank you.
    oracle EBS training

    ReplyDelete
  2. Thanks for sharing nice article, the information in the article explained in a detailed way. Hope you will share many more articles like this.

    Oracle Fusion Financials Online Training

    ReplyDelete
  3. Hey Really Thanks for sharing the best information regarding java,hope you will write more great blogs.

    oracle fusion financials online training

    ReplyDelete
  4. I really like and appreciate your post.Really thank you! Fantastic.devops online training
    devops training

    ReplyDelete