Showing posts with label JBoss. Show all posts
Showing posts with label JBoss. Show all posts

Sunday, February 21, 2021

JBoss Wildfly Kubernetes Operator

 HOWTO

 

GitHub repos


Build JBoss Wildfly Docker image GitHub repo https://github.com/dveselka/java-ee-8/tree/main/java-ee8-minimal Dockerfile
$ more Dockerfile
FROM jboss/wildfly

RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#123 --silent

COPY ./target/java-ee8-minimal.war /opt/jboss/wildfly/standalone/deployments/

CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]

Build Docker image

mvn clean package && docker build -t dveselka/java-ee8-minimal .
....

Sending build context to Docker daemon  111.6kB
Step 1/4 : FROM jboss/wildfly
latest: Pulling from jboss/wildfly
75f829a71a1c: Pull complete 
7b11f246b3d3: Pull complete 
b765648c2a58: Pull complete 
506aff4a9c5a: Pull complete 
a7ae73eec52a: Pull complete 
Digest: sha256:c0be1b7462a7ee9d07be5e319f7f2b10a93e5b43d51532ed012d2869e0224cf0
Status: Downloaded newer image for jboss/wildfly:latest
 ---> 13b4b5beba73
Step 2/4 : RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#123 --silent
 ---> Running in ecb1651c51fc
Removing intermediate container ecb1651c51fc
 ---> 74f6e50296e9
Step 3/4 : COPY ./target/java-ee8-minimal.war /opt/jboss/wildfly/standalone/deployments/
 ---> dd07d8a883fc
Step 4/4 : CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
 ---> Running in d9575f15ea43
Removing intermediate container d9575f15ea43
 ---> 01e0043e9e6f
Successfully built 01e0043e9e6f
Successfully tagged dveselka/java-ee8-minimal:latest

Docker image
[dave@dave java-ee8-minimal]$ docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
dveselka/java-ee8-minimal       latest              01e0043e9e6f        3 minutes ago       714MB

Push Docker image to DockerHub
$ docker push   dveselka/java-ee8-minimal
The push refers to repository [docker.io/dveselka/java-ee8-minimal]
4a24521ab9d6: Pushed 
348cd5508b6f: Pushed 
9ef61a25476f: Mounted from jboss/wildfly 
869989761eb2: Mounted from jboss/wildfly 
3fbe1e874b0d: Mounted from jboss/wildfly 
115463be137a: Mounted from jboss/wildfly 
613be09ab3c0: Mounted from jboss/wildfly 
latest: digest: sha256:d416275117d084e0cf557f6cf1ad82dc0aba7bf67921e4f19703e9a48701b2ec size: 1790

Run in k8s
$ kubectl run java-ee8-minimal --image=dveselka/java-ee8-minimal
Get k8s pods
 kubectl get pods
NAME               READY   STATUS             RESTARTS   AGE
java-ee8-minimal   0/1     ImagePullBackOff   0          12s
Minikube running in Docker
$ docker ps
CONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS              PORTS                                                                                                                                  NAMES
5f6397acb7e1        gcr.io/k8s-minikube/kicbase:v0.0.18   "/usr/local/bin/entr…"   21 hours ago        Up 22 minutes       127.0.0.1:32772->22/tcp, 127.0.0.1:32771->2376/tcp, 127.0.0.1:32770->5000/tcp, 127.0.0.1:32769->8443/tcp, 127.0.0.1:32768->32443/tcp   minikube

Start k8s dashboard
$ kubectl cluster-info 
Kubernetes control plane is running at https://172.17.0.2:8443
KubeDNS is running at https://172.17.0.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
[dave@dave java-ee8-minimal]$ minikube dashboard
🔌  Enabling dashboard ...
    ▪ Using image kubernetesui/dashboard:v2.1.0
    ▪ Using image kubernetesui/metrics-scraper:v1.0.4
🤔  Verifying dashboard health ...
🚀  Launching proxy ...
🤔  Verifying proxy health ...
🎉  Opening http://127.0.0.1:43609/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...

Forward k8s port to host
$ kubectl port-forward java-ee8-minimal 9990:9990
Forwarding from 127.0.0.1:9990 -> 9990
Forwarding from [::1]:9990 -> 9990
Handling connection for 9990

Check connection to app
$ wget http://localhost:8080/
--2021-03-14 17:28:48--  http://localhost:8080/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1504 (1.5K) [text/html]
Saving to: ‘index.html’

Call application resource
 curl http://localhost:8080/java-ee8-minimal/resources/ping
Enjoy Jakarta EE with MicroProfile 2+
Minikube dashboard with pod
Create deployment on k8s cluster
$ kubectl apply -f app.yml 
deployment.apps/java-ee8-minimal created
[dave@dave java-ee8-minimal]$ kubectl get pods
NAME                                READY   STATUS              RESTARTS   AGE
java-ee8-minimal-76cd57679d-l5smd   0/1     ContainerCreating   0          3s
java-ee8-minimal-76cd57679d-swvcd   0/1     ContainerCreating   0          3s

k8s deployment https://github.com/dveselka/java-ee-8/blob/main/java-ee8-minimal/app.yml
 more app.yml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: java-ee8-minimal
spec:
  selector:
    matchLabels:
      app: java-ee8
  replicas: 2 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: java-ee8
    spec:
      containers:
      - name: java-ee8-minimal
        image: dveselka/java-ee8-minimal
        ports:
        - containerPort: 8080

Check pods
[dave@dave java-ee8-minimal]$ kubectl get pods -l app=java-ee8 -o wide
NAME                                READY   STATUS    RESTARTS   AGE     IP           NODE       NOMINATED NODE   READINESS GATES
java-ee8-minimal-76cd57679d-l5smd   1/1     Running   0          3m35s   172.18.0.5   minikube   <none>           <none>
java-ee8-minimal-76cd57679d-swvcd   1/1     Running   0          3m35s   172.18.0.6   minikube   <none>           <none>

Export port - service https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/
dave@dave java-ee8-minimal]$ kubectl expose deployment/java-ee8-minimal
service/java-ee8-minimal exposed
[dave@dave java-ee8-minimal]$ curl 172.18.0.5:8080
curl: (7) Failed to connect to 172.18.0.5 port 8080: No route to host
[dave@dave java-ee8-minimal]$ kubectl get pods -l app=java-ee8 -o wide |grep podIP
[dave@dave java-ee8-minimal]$ kubectl get pods -l app=java-ee8 -o wide 
NAME                                READY   STATUS    RESTARTS   AGE     IP           NODE       NOMINATED NODE   READINESS GATES
java-ee8-minimal-76cd57679d-l5smd   1/1     Running   0          5m28s   172.18.0.5   minikube   <none>           <none>
java-ee8-minimal-76cd57679d-swvcd   1/1     Running   0          5m28s   172.18.0.6   minikube   <none>           <none>
[dave@dave java-ee8-minimal]$ kubectl get svc java-ee8-minimal
NAME               TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
java-ee8-minimal   ClusterIP   10.103.186.17   <none>        8080/TCP   35s
[dave@dave java-ee8-minimal]$ kubectl get svc java-ee8-minimal
NAME               TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
java-ee8-minimal   ClusterIP   10.103.186.17   <none>        8080/TCP   40s
[dave@dave java-ee8-minimal]$ kubectl get ep java-ee8-minimal
NAME               ENDPOINTS                         AGE
java-ee8-minimal   172.18.0.5:8080,172.18.0.6:8080   61s
[dave@dave java-ee8-minimal]$ curl 172.18.0.5:8080/java-ee8-minimal/resources/ping
curl: (7) Failed to connect to 172.18.0.5 port 8080: No route to host
[dave@dave java-ee8-minimal]$ kubectl exec my-nginx-3800858182-jr4a2 -- printenv | grep SERVICE^C
[dave@dave java-ee8-minimal]$ kubectl get pods
NAME                                READY   STATUS    RESTARTS   AGE
java-ee8-minimal-76cd57679d-l5smd   1/1     Running   0          7m18s
java-ee8-minimal-76cd57679d-swvcd   1/1     Running   0          7m18s
[dave@dave java-ee8-minimal]$ kubectl exec java-ee8-minimal-76cd57679d-l5smd -- printenv | grep SERVICE
KUBERNETES_SERVICE_PORT=443
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_SERVICE_HOST=10.96.0.1
[dave@dave java-ee8-minimal]$ kubectl get services kube-dns --namespace=kube-system
NAME       TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
kube-dns   ClusterIP   10.96.0.10   <none>        53/UDP,53/TCP,9153/TCP   26h
[dave@dave java-ee8-minimal]$ kubectl run curl --image=radial/busyboxplus:curl -i --tty
If you don't see a command prompt, try pressing enter.
[ root@curl:/ ]$ nslookup  java-ee8-minimal
Server:    10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

nslookup: can't resolve 'java-ee8-minimal'
[ root@curl:/ ]$ curl 172.18.0.5:8080/java-ee8-minimal/resources/ping

Add ingress https://kubernetes.io/docs/concepts/services-networking/ingress/ https://github.com/dveselka/java-ee-8/blob/main/java-ee8-minimal/ingress.yaml
$ kubectl apply -f ingress.yaml 
ingress.networking.k8s.io/java-ee8-ingress configured
[dave@dave java-ee8-minimal]$ kubectl describe ingress  java-ee8-ingress
Name:             java-ee8-ingress
Namespace:        default
Address:          
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host        Path  Backends
  ----        ----  --------
  *           
              /java-ee8-minimal   java-ee8-minimal:8080 (172.18.0.5:8080,172.18.0.6:8080)
Annotations:  nginx.ingress.kubernetes.io/rewrite-target: /
Events:       <none>

SSH into container inside k8s cluster

[dave@dave java-ee8-minimal]$ kubectl get pods
NAME                                READY   STATUS    RESTARTS   AGE
curl                                1/1     Running   1          3h49m
java-ee8-minimal-76cd57679d-l5smd   1/1     Running   0          3h58m
java-ee8-minimal-76cd57679d-swvcd   1/1     Running   0          3h58m
[dave@dave java-ee8-minimal]$ kubectl exec --stdin --tty java-ee8-minimal-76cd57679d-l5smd  -- /bin/bash
[jboss@java-ee8-minimal-76cd57679d-l5smd ~]$ curl localhost:8080/java-ee8-minimal/resources/ping
Enjoy Jakarta EE with MicroProfile 2+!
Add JBOss Wildfly admin user
[jboss@java-ee8-minimal-76cd57679d-l5smd ~]$ cd wildfly/
[jboss@java-ee8-minimal-76cd57679d-l5smd wildfly]$ ls
LICENSE.txt  README.txt  appclient  bin  copyright.txt  docs  domain  jboss-modules.jar  modules  standalone  welcome-content
[jboss@java-ee8-minimal-76cd57679d-l5smd wildfly]$ cd bin
[jboss@java-ee8-minimal-76cd57679d-l5smd bin]$ ./add-user.sh

What type of user do you wish to add? 
 a) Management User (mgmt-users.properties) 
 b) Application User (application-users.properties)
(a): 

Access Wildfly admin console Forward admin port
$ kubectl port-forward  java-ee8-minimal-76cd57679d-l5smd 9990:9990
Forwarding from 127.0.0.1:9990 -> 9990
Forwarding from [::1]:9990 -> 9990
Handling connection for 9990

Access console via browser using
http://localhost:9990/console
Access JBoss using minikube service
$ minikube service java-ee8-service
|-----------|------------------|-------------|-------------------------|
| NAMESPACE |       NAME       | TARGET PORT |           URL           |
|-----------|------------------|-------------|-------------------------|
| default   | java-ee8-service |        8080 | http://172.17.0.2:30919 |
|-----------|------------------|-------------|-------------------------|
🎉  Opening service default/java-ee8-service in default browser...

Instance running at http://172.17.0.2:30919/
$ wget -O - http://172.17.0.2:30919 
--2021-03-20 09:33:06--  http://172.17.0.2:30919/
Connecting to 172.17.0.2:30919... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1504 (1.5K) [text/html]
Saving to: ‘STDOUT’

-                                         0%[                                                                                ]       0  --.-KB/s               <!DOCTYPE html>

<html>
<head>
    <!-- proper charset -->
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

    <title>Welcome to WildFly</title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="StyleSheet" href="wildfly.css" type="text/css">
</head>

<body>
<div class="wrapper">
    <div class="content">
        <div class="logo">
                <img src="wildfly_logo.png" alt="WildFly" border="0" />
        </div>
        <h1>Welcome to WildFly</h1>

        <h3>Your WildFly instance is running.</h3>

        <p><a href="https://docs.wildfly.org">Documentation</a> | <a href="https://github.com/wildfly/quickstart">Quickstarts</a> | <a href="/console">Administration
            Console</a> </p>

        <p><a href="https://wildfly.org">WildFly Project</a> |
            <a href="https://community.jboss.org/en/wildfly">User Forum</a> |
            <a href="https://issues.jboss.org/browse/WFLY">Report an issue</a></p>
        <p class="logos"><a href="https://www.jboss.org"><img src="jbosscommunity_logo_hori_white.png" alt="JBoss and JBoss Community" width=
                "195" height="37" border="0"></a></p>

        <p class="note">To replace this page simply deploy your own war with / as its context path.<br />
            To disable it, remove the "welcome-content" handler for location / in the undertow subsystem.</p>
    </div>
</div>
</body>
</html>
-                                       100%[===============================================================================>]   1.47K  --.-KB/s    in 0s      

2021-03-20 09:33:06 (36.7 MB/s) - written to stdout [1504/1504]

Sunday, December 27, 2020

Deploy JBoss Wildfly Java EE app with Maven using Jenkins pipeline and Docker

 HOWTO

 

GitHub projects


Pipeline file https://github.com/dveselka/java-ee-8/blob/main/java-ee8-minimal/Jenkinsfile

Add jenkins user into docker group

sudo usermod -aG docker jenkins
sudo systemctl restart jenkins

Checkout app from GitHub

        stage('Checkout') {
          git url: 'https://github.com/dveselka/java-ee-8/', credentialsId: 'dave-devops', branch: 'main'
        }

 

Build application using Maven

        stage('Build') {
          
          dir('java-ee8-minimal'){
             withMaven(maven:'Maven'
             ) {
                sh 'pwd'
                sh 'env'
                sh 'mvn clean package'
            
                def pom = readMavenPom file:'pom.xml'
                print pom.version
                env.version = pom.version
             }
          }
        }

 

Build Docker image

https://www.jenkins.io/doc/book/pipeline/docker/
        stage("BuildDockerImage"){
          dir('java-ee8-minimal'){
            def customImage = docker.build("my-image:${env.BUILD_ID}")
          }
        }
Jenkins log - Docker image build
[Pipeline] { (Image)
[Pipeline] dir
Running in /var/lib/jenkins/workspace/java-ee-8/java-ee8-minimal
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker build -t com.dave/java-ee8-minimal:4 .
Sending build context to Docker daemon  46.59kB

Step 1/4 : FROM jboss/wildfly
 ---> 8d9094a2468d
Step 2/4 : RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#123 --silent
 ---> Using cache
 ---> 8b8272a09327
Step 3/4 : COPY ./target/java-ee8-minimal.war /opt/jboss/wildfly/standalone/deployments/
 ---> 229ba08da529
Step 4/4 : CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
 ---> Running in fdea8bab71ee
Removing intermediate container fdea8bab71ee
 ---> c165d87af41e
Successfully built c165d87af41e
Successfully tagged com.dave/java-ee8-minimal:4

 

Push Docker image to repository (optional)

 

Run container

        stage ('Run') {
          dir('java-ee8-minimal'){
            docker.image("com.dave/java-ee8-minimal:${env.BUILD_ID}").run('-it --name java-ee8-minimal com.dave/java-ee8-minimal')
          }
        }

 

Install Jenkins Docker plugin to remove this error

groovy.lang.MissingPropertyException: No such property: docker for class: groovy.lang.Binding
    at groovy.lang.Binding.getVariable(Binding.java:63)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:270)

 
Jenkins log - run Docker container

[Pipeline] { (Run)
[Pipeline] dir
Running in /var/lib/jenkins/workspace/java-ee-8/java-ee8-minimal
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker run -d -it --name java-ee8-minimal com.dave/java-ee8-minimal:6
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
Docker process
docker ps -a
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS               NAMES
0eb3d2588c6b        com.dave/java-ee8-minimal:6   "/opt/jboss/wildfly/…"   2 minutes ago       Up 2 minutes        8080/tcp            java-ee8-minimal

Deploy Java EE 8 application into JBoss Wildfy AS running on Docker

HOWTO

 

GitHub projects

Start JBoss Wildfly using Docker

[dave@dave java-ee-8]$ docker run -it jboss/wildfly
Unable to find image 'jboss/wildfly:latest' locally
latest: Pulling from jboss/wildfly
75f829a71a1c: Pull complete 
7b11f246b3d3: Pull complete 
b765648c2a58: Pull complete 
506aff4a9c5a: Pull complete 
e7e0b6e22530: Pull complete 
Digest: sha256:152a4dd6e524afa133dd200b1a4ba6411dc334dfd84921d5eafcbae85f859c00
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  --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED

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

10:40:59,521 INFO  [org.jboss.modules] (main) JBoss Modules version 1.10.2.Final
10:41:00,013 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.12.Final
10:41:00,021 INFO  [org.jboss.threads] (main) JBoss Threads version 2.4.0.Final
10:41:00,093 WARN  [org.jboss.as.warn.fd-limit] (main) WFLYSRV0071: The operating system has limited the number of open files to 1024 for this process; a value of at least 4096 is recommended
10:41:00,133 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Full 21.0.1.Final (WildFly Core 13.0.3.Final) starting
10:41:00,961 INFO  [org.wildfly.security] (ServerService Thread Pool -- 27) ELY00001: WildFly Elytron version 1.13.1.Final
10:41:01,501 INFO  [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
10:41:01,542 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 36) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
10:41:01,611 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
10:41:01,626 INFO  [org.xnio] (MSC service thread 1-5) XNIO version 3.8.2.Final
10:41:01,631 INFO  [org.xnio.nio] (MSC service thread 1-5) XNIO NIO Implementation Version 3.8.2.Final
10:41:01,671 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 52) WFLYCLINF0001: Activating Infinispan subsystem.
10:41:01,685 INFO  [org.wildfly.extension.microprofile.jwt.smallrye._private] (ServerService Thread Pool -- 63) WFLYJWT0001: Activating WildFly MicroProfile JWT Subsystem
10:41:01,693 INFO  [org.wildfly.extension.microprofile.config.smallrye._private] (ServerService Thread Pool -- 61) WFLYCONF0001: Activating WildFly MicroProfile Config Subsystem
10:41:01,700 INFO  [org.jboss.remoting] (MSC service thread 1-3) JBoss Remoting version 5.0.19.Final
10:41:01,709 INFO  [org.wildfly.extension.microprofile.health.smallrye] (ServerService Thread Pool -- 62) WFLYHEALTH0001: Activating Eclipse MicroProfile Health Subsystem
10:41:01,711 INFO  [org.jboss.as.jaxrs] (ServerService Thread Pool -- 54) WFLYRS0016: RESTEasy version 3.13.2.Final
10:41:01,718 WARN  [org.wildfly.extension.io] (ServerService Thread Pool -- 53) WFLYIO005: Your system is configured with 1024 file descriptors, but your current application server configuration will require a minimum of 1032 (and probably more than that); attempting to adjust, however you should expect stability problems unless you increase this number
10:41:01,725 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 76) WFLYWS0002: Activating WebServices Extension
10:41:01,726 INFO  [org.wildfly.extension.microprofile.metrics.smallrye] (ServerService Thread Pool -- 64) WFLYMETRICS0001: Activating Eclipse MicroProfile Metrics Subsystem
10:41:01,696 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 74) WFLYTX0013: The node-identifier attribute on the /subsystem=transactions is set to the default value. This is a danger for environments running multiple servers. Please make sure the attribute value is unique.
10:41:01,733 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 59) WFLYJSF0007: Activated the following JSF Implementations: [main]
10:41:01,733 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 72) WFLYSEC0002: Activating Security Subsystem
10:41:01,739 INFO  [org.wildfly.extension.microprofile.opentracing] (ServerService Thread Pool -- 65) WFLYTRACEXT0001: Activating MicroProfile OpenTracing Subsystem
10:41:01,741 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 53) WFLYIO001: Worker 'default' has auto-configured to 16 IO threads with 128 max task threads based on your 8 available processors
10:41:01,740 INFO  [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=5.0.3.Final-redhat-00006
10:41:01,735 INFO  [org.jboss.as.connector] (MSC service thread 1-8) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.23.Final)
10:41:01,759 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 66) WFLYNAM0001: Activating Naming Subsystem
10:41:01,780 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0003: Undertow 2.2.2.Final starting
10:41:01,849 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 44) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
10:41:01,864 INFO  [org.jboss.as.naming] (MSC service thread 1-2) WFLYNAM0003: Starting Naming Service
10:41:01,869 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-3) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
10:41:01,881 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = h2
10:41:02,030 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 75) WFLYUT0014: Creating file handler for path '/opt/jboss/wildfly/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
10:41:02,043 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0012: Started server default-server.
10:41:02,046 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0018: Host default-host starting
10:41:02,051 INFO  [org.jboss.as.ejb3] (MSC service thread 1-6) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 128 (per class), which is derived from thread worker pool sizing.
10:41:02,051 INFO  [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 32 (per class), which is derived from the number of CPUs on this host.
10:41:02,194 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0006: Undertow HTTP listener default listening on 0.0.0.0:8080
10:41:02,297 INFO  [org.jboss.as.ejb3] (MSC service thread 1-5) WFLYEJB0493: EJB subsystem suspension complete
10:41:02,381 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
10:41:02,549 INFO  [org.jboss.as.patching] (MSC service thread 1-2) WFLYPAT0050: WildFly Full cumulative patch ID is: base, one-off patches include: none
10:41:02,568 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-2) WFLYDM0111: Keystore /opt/jboss/wildfly/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
10:41:02,580 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) WFLYDS0013: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
10:41:02,668 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTPS listener https listening on 0.0.0.0:8443
10:41:02,763 INFO  [org.jboss.ws.common.management] (MSC service thread 1-3) JBWS022052: Starting JBossWS 5.4.2.Final (Apache CXF 3.3.7) 
10:41:02,946 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
10:41:02,949 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 21.0.1.Final (WildFly Core 13.0.3.Final) started in 3839ms - Started 317 of 579 services (370 services are lazy, passive or on-demand)
10:41:02,951 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
10:41:02,951 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990

 

SSH into Docker container
[dave@dave java-ee-8]$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
32092f4064f8        jboss/wildfly       "/opt/jboss/wildfly/…"   4 minutes ago       Up 4 minutes        8080/tcp            thirsty_mccarthy
[dave@dave java-ee-8]$ docker exec -it thirsty_mccarthy /bin/bash
[jboss@32092f4064f8 ~]$ uname -a
Linux 32092f4064f8 5.9.15-100.fc32.x86_64 #1 SMP Wed Dec 16 16:49:20 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[jboss@32092f4064f8 ~]$ more /etc/re
redhat-release  resolv.conf     
[jboss@32092f4064f8 ~]$ more /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)
[jboss@32092f4064f8 ~]$ ls /opt/jboss/
.bash_logout   .bash_profile  .bashrc        wildfly/       
[jboss@32092f4064f8 ~]$ ls /opt/jboss/
.bash_logout   .bash_profile  .bashrc        wildfly/       
[jboss@32092f4064f8 ~]$ ls /opt/jboss/wildfly/
.installation/     LICENSE.txt        appclient/         copyright.txt      domain/            modules/           welcome-content/   
.well-known/       README.txt         bin/               docs/              jboss-modules.jar  standalone/     

 Start the container with port mapping


[dave@dave java-ee8-minimal]$ docker run -it com.dave/java-ee8-minimal /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement=0.0.0.0
=========================================================================

  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  --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED

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

11:05:36,608 INFO  [org.jboss.modules] (main) JBoss Modules version 1.10.2.Final
11:05:37,223 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.12.Final
11:05:37,235 INFO  [org.jboss.threads] (main) JBoss Threads version 2.4.0.Final
11:05:37,349 WARN  [org.jboss.as.warn.fd-limit] (main) WFLYSRV0071: The operating system has limited the number of open files to 1024 for this process; a value of at least 4096 is recommended
11:05:37,409 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: WildFly Full 21.0.1.Final (WildFly Core 13.0.3.Final) starting

 

Create custom Docker image with added start command and admin user



$ more Dockerfile
FROM jboss/wildfly

RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#123 --silent

COPY ./target/java-ee8-minimal.war /opt/jboss/wildfly/standalone/deployments/

CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]



$ docker build -t com.dave/java-ee8-minimal .
Sending build context to Docker daemon  45.06kB
Step 1/4 : FROM jboss/wildfly
latest: Pulling from jboss/wildfly
75f829a71a1c: Pull complete 
7b11f246b3d3: Pull complete 
b765648c2a58: Pull complete 
506aff4a9c5a: Pull complete 
e7e0b6e22530: Pull complete 
Digest: sha256:152a4dd6e524afa133dd200b1a4ba6411dc334dfd84921d5eafcbae85f859c00
Status: Downloaded newer image for jboss/wildfly:latest
 ---> 8d9094a2468d
Step 2/4 : RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#123 --silent
 ---> Running in aa5d352002f3
Removing intermediate container aa5d352002f3
 ---> 8b8272a09327
Step 3/4 : COPY ./target/java-ee8-minimal.war /opt/jboss/wildfly/standalone/deployments/
 ---> cc421f2ffe58
Step 4/4 : CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
 ---> Running in 1dc6700a5950
Removing intermediate container 1dc6700a5950
 ---> fc3355adcac3
Successfully built fc3355adcac3
Successfully tagged com.dave/java-ee8-minimal:latest


Get IP address

$$ docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS               NAMES
ba4374f6cbb1        com.dave/java-ee8-minimal   "/opt/jboss/wildfly/…"   4 minutes ago       Up 4 minutes        8080/tcp            java-ee8-minimal
[dave@dave java-ee-8]$ docker inspect -f '{{ .NetworkSettings.IPAddress }}' java-ee8-minimal
172.17.0.2

Start the mofified container with mapped ports and added admin user

[dave@dave java-ee8-minimal]$ docker run -it --name java-ee8-minimal com.dave/java-ee8-minimal
=========================================================================

  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  --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED

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

11:18:28,581 INFO  [org.jboss.modules] (main) JBoss Modules version 1.10.2.Final
11:18:29,127 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.12.Final
11:18:29,135 INFO  [org.jboss.threads] (main) JBoss Threads version 2.4.0.Final
11:18:29,219 WARN  [org.jboss.as.warn.fd-limit] (main) WFLYSRV0071: The operating system has limited the number of open files to 1024 for this process; a value of at least 4096 is recommended
11:18:29,286 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: WildFly Full 21.0.1.Final (WildFly Core 13.0.3.Final) starting
11:18:30,137 INFO  [org.wildfly.security] (ServerService Thread Pool -- 28) ELY00001: WildFly Elytron version 1.13.1.Final
11:18:30,739 INFO  [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
11:18:30,782 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 21) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
11:18:30,819 INFO  [org.jboss.as.repository] (ServerService Thread Pool -- 9) WFLYDR0001: Content added at location /opt/jboss/wildfly/standalone/data/content/9a/599d68cb6a082432b9ec80cfbc307a3345471e/content
11:18:30,905 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
11:18:30,921 INFO  [org.xnio] (MSC service thread 1-8) XNIO version 3.8.2.Final
11:18:30,928 INFO  [org.xnio.nio] (MSC service thread 1-8) XNIO NIO Implementation Version 3.8.2.Final
11:18:30,982 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 52) WFLYCLINF0001: Activating Infinispan subsystem.
11:18:30,969 WARN  [org.wildfly.extension.io] (ServerService Thread Pool -- 53) WFLYIO005: Your system is configured with 1024 file descriptors, but your current application server configuration will require a minimum of 1032 (and probably more than that); attempting to adjust, however you should expect stability problems unless you increase this number
11:18:31,001 INFO  [org.jboss.as.jaxrs] (ServerService Thread Pool -- 54) WFLYRS0016: RESTEasy version 3.13.2.Final
11:18:31,003 INFO  [org.jboss.as.connector] (MSC service thread 1-7) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.23.Final)
11:18:31,022 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 44) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
11:18:31,038 INFO  [org.wildfly.extension.microprofile.metrics.smallrye] (ServerService Thread Pool -- 64) WFLYMETRICS0001: Activating Eclipse MicroProfile Metrics Subsystem
11:18:31,038 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = h2
11:18:31,066 INFO  [org.wildfly.extension.microprofile.jwt.smallrye._private] (ServerService Thread Pool -- 63) WFLYJWT0001: Activating WildFly MicroProfile JWT Subsystem
11:18:31,038 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 59) WFLYJSF0007: Activated the following JSF Implementations: [main]
11:18:31,069 INFO  [org.wildfly.extension.microprofile.health.smallrye] (ServerService Thread Pool -- 62) WFLYHEALTH0001: Activating Eclipse MicroProfile Health Subsystem
11:18:31,069 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 5.0.19.Final
11:18:31,079 INFO  [org.wildfly.extension.microprofile.opentracing] (ServerService Thread Pool -- 65) WFLYTRACEXT0001: Activating MicroProfile OpenTracing Subsystem
11:18:31,079 INFO  [org.wildfly.extension.microprofile.config.smallrye._private] (ServerService Thread Pool -- 61) WFLYCONF0001: Activating WildFly MicroProfile Config Subsystem
11:18:31,083 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 53) WFLYIO001: Worker 'default' has auto-configured to 16 IO threads with 128 max task threads based on your 8 available processors
11:18:31,100 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 72) WFLYSEC0002: Activating Security Subsystem
11:18:31,105 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 66) WFLYNAM0001: Activating Naming Subsystem
11:18:31,099 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 74) WFLYTX0013: The node-identifier attribute on the /subsystem=transactions is set to the default value. This is a danger for environments running multiple servers. Please make sure the attribute value is unique.
11:18:31,103 INFO  [org.jboss.as.security] (MSC service thread 1-3) WFLYSEC0001: Current PicketBox version=5.0.3.Final-redhat-00006
11:18:31,135 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 76) WFLYWS0002: Activating WebServices Extension
11:18:31,153 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0003: Undertow 2.2.2.Final starting
11:18:31,197 INFO  [org.jboss.as.naming] (MSC service thread 1-8) WFLYNAM0003: Starting Naming Service
11:18:31,208 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-8) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
11:18:31,356 INFO  [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 32 (per class), which is derived from the number of CPUs on this host.
11:18:31,358 INFO  [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 128 (per class), which is derived from thread worker pool sizing.
11:18:31,369 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 75) WFLYUT0014: Creating file handler for path '/opt/jboss/wildfly/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
11:18:31,382 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0012: Started server default-server.
11:18:31,400 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0018: Host default-host starting
11:18:31,507 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 0.0.0.0:8080
11:18:31,571 INFO  [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0493: EJB subsystem suspension complete
11:18:31,643 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
11:18:31,878 INFO  [org.jboss.as.patching] (MSC service thread 1-3) WFLYPAT0050: WildFly Full cumulative patch ID is: base, one-off patches include: none
11:18:31,896 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-8) WFLYDM0111: Keystore /opt/jboss/wildfly/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
11:18:31,910 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) WFLYDS0013: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
11:18:31,919 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "java-ee8-minimal.war" (runtime-name: "java-ee8-minimal.war")
11:18:31,989 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTPS listener https listening on 0.0.0.0:8443
11:18:32,071 INFO  [org.jboss.ws.common.management] (MSC service thread 1-8) JBWS022052: Starting JBossWS 5.4.2.Final (Apache CXF 3.3.7) 
11:18:32,618 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0003: Processing weld deployment java-ee8-minimal.war
11:18:32,877 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-4) HV000001: Hibernate Validator 6.0.21.Final
11:18:33,273 INFO  [io.jaegertracing.internal.JaegerTracer] (MSC service thread 1-4) No shutdown hook registered: Please call close() manually on application shutdown.
11:18:33,390 INFO  [org.jboss.weld.Version] (MSC service thread 1-3) WELD-000900: 3.1.5 (Final)
11:18:33,681 INFO  [org.infinispan.CONTAINER] (ServerService Thread Pool -- 78) ISPN000128: Infinispan version: Infinispan 'Corona Extra' 11.0.4.Final
11:18:33,743 INFO  [org.infinispan.CONFIG] (MSC service thread 1-1) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
11:18:33,745 INFO  [org.infinispan.CONFIG] (MSC service thread 1-1) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
11:18:33,870 INFO  [org.infinispan.PERSISTENCE] (ServerService Thread Pool -- 78) ISPN000556: Starting user marshaller 'org.wildfly.clustering.infinispan.spi.marshalling.InfinispanProtoStreamMarshaller'
11:18:33,934 INFO  [io.smallrye.metrics] (MSC service thread 1-4) MicroProfile: Metrics activated (SmallRye Metrics version: 2.4.2)
11:18:34,134 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 78) WFLYCLINF0002: Started http-remoting-connector cache from ejb container
11:18:34,899 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 79) RESTEASY002225: Deploying javax.ws.rs.core.Application: class com.airhacks.JAXRSConfiguration$Proxy$_$$_WeldClientProxy
11:18:34,959 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 79) WFLYUT0021: Registered web context: '/java-ee8-minimal' for server 'default-server'
11:18:35,066 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 45) WFLYSRV0010: Deployed "java-ee8-minimal.war" (runtime-name : "java-ee8-minimal.war")
11:18:35,129 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
11:18:35,133 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 21.0.1.Final (WildFly Core 13.0.3.Final) started in 7081ms - Started 441 of 664 services (375 services are lazy, passive or on-demand)
11:18:35,136 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://0.0.0.0:9990/management
11:18:35,136 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://0.0.0.0:9990


Access the Admin console at port 9990 

Access the application at http://172.17.0.2:8080/java-ee8-minimal/resources/ping

Enjoy Jakarta EE with MicroProfile 2+!

 

Friday, October 26, 2018

JBoss Thorntail

https://thorntail.io/

https://thorntail.io/generator/


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.dave</groupId>
  <artifactId>demo-thorntail</artifactId>
  <name>Thorntail Example</name>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <properties>
    <version.thorntail>2.2.0.Final</version.thorntail>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.thorntail</groupId>
        <artifactId>bom-all</artifactId>
        <version>${version.thorntail}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <finalName>demo</finalName>
    <plugins>
      <plugin>
        <groupId>io.thorntail</groupId>
        <artifactId>thorntail-maven-plugin</artifactId>
        <version>${version.thorntail}</version>

        <executions>
          <execution>
            <goals>
              <goal>package</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>

    <dependency>
      <groupId>io.thorntail</groupId>
      <artifactId>jaxrs</artifactId>
    </dependency><dependency>
      <groupId>io.thorntail</groupId>
      <artifactId>jpa</artifactId>
    </dependency>
  </dependencies>
</project>


HelloWorldEndpoin.java

package com.dave.demothorntail.rest;


import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;


@Path("/hello")
public class HelloWorldEndpoint {

        @GET
        @Produces("text/plain")
        public Response doGet() {
                return Response.ok("Hello from Thorntail!").build();
        }
}



RestApplication

package com.dave.demothorntail.rest;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/")
public class RestApplication extends Application {

}




mvn install

mvn thorntail:run



[INFO] Starting .war
Fri Oct 26 16:40:36 CEST 2018 INFO [org.wildfly.swarm.bootstrap] (main) Dependencies not bundled; resolving from M2REPO.
2018-10-26 16:40:42,986 INFO  [org.wildfly.swarm] (main) THORN0013: Installed fraction:                   JAX-RS - STABLE          io.thorntail:jaxrs:2.2.0.Final
2018-10-26 16:40:42,997 INFO  [org.wildfly.swarm] (main) THORN0013: Installed fraction:                  Logging - STABLE          io.thorntail:logging:2.2.0.Final
2018-10-26 16:40:42,997 INFO  [org.wildfly.swarm] (main) THORN0013: Installed fraction:                 Undertow - STABLE          io.thorntail:undertow:2.2.0.Final
2018-10-26 16:40:42,999 INFO  [org.wildfly.swarm] (main) THORN0013: Installed fraction:                  Elytron - STABLE          io.thorntail:elytron:2.2.0.Final
2018-10-26 16:40:43,000 INFO  [org.wildfly.swarm] (main) THORN0013: Installed fraction:                      JPA - STABLE          io.thorntail:jpa:2.2.0.Final
2018-10-26 16:40:43,000 INFO  [org.wildfly.swarm] (main) THORN0013: Installed fraction:              Datasources - STABLE          io.thorntail:datasources:2.2.0.Final
2018-10-26 16:40:43,001 INFO  [org.wildfly.swarm] (main) THORN0013: Installed fraction:                      JCA - STABLE          io.thorntail:jca:2.2.0.Final
2018-10-26 16:40:43,001 INFO  [org.wildfly.swarm] (main) THORN0013: Installed fraction:             Transactions - STABLE          io.thorntail:transactions:2.2.0.Final
2018-10-26 16:40:46,101 WARN  [org.wildfly.swarm.datasources] (main) THORN1005: Not creating a default datasource due to lack of JDBC driver
2018-10-26 16:40:47,061 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.7.SP1
2018-10-26 16:40:47,304 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: Thorntail 2.2.0.Final (WildFly Core 3.0.8.Final) starting
2018-10-26 16:40:47,554 INFO  [org.wildfly.swarm] (MSC service thread 1-1) THORN0019: Install MSC service for command line args: []
2018-10-26 16:40:50,300 INFO  [org.wildfly.security] (ServerService Thread Pool -- 12) ELY00001: WildFly Elytron version 1.1.6.Final
2018-10-26 16:40:50,374 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 16) WFLYTX0013: The node-identifier attribute on the /subsystem=transactions is set to the default value. This is a danger for environments running multiple servers. Please make sure the attribute value is unique.
2018-10-26 16:40:50,375 INFO  [org.jboss.as.jaxrs] (ServerService Thread Pool -- 15) WFLYRS0016: RESTEasy version 3.0.24.Final
2018-10-26 16:40:50,388 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 23) WFLYNAM0001: Activating Naming Subsystem
2018-10-26 16:40:50,454 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 20) WFLYSEC0002: Activating Security Subsystem
2018-10-26 16:40:50,459 INFO  [org.xnio] (ServerService Thread Pool -- 24) XNIO version 3.5.4.Final
2018-10-26 16:40:50,754 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0003: Undertow 1.4.18.Final starting
2018-10-26 16:40:50,792 INFO  [org.xnio.nio] (ServerService Thread Pool -- 24) XNIO NIO Implementation Version 3.5.4.Final
2018-10-26 16:40:50,804 INFO  [org.jboss.as.security] (MSC service thread 1-2) WFLYSEC0001: Current PicketBox version=5.0.2.Final
2018-10-26 16:40:50,988 INFO  [org.jboss.as.connector] (MSC service thread 1-3) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.6.Final)
2018-10-26 16:40:51,511 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 24) WFLYIO001: Worker 'default' has auto-configured to 4 core threads with 32 task threads based on your 2 available processors
2018-10-26 16:40:51,583 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0012: Started server default-server.
2018-10-26 16:40:51,610 INFO  [org.jboss.as.naming] (MSC service thread 1-4) WFLYNAM0003: Starting Naming Service
2018-10-26 16:40:51,691 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTP listener default listening on [0:0:0:0:0:0:0:0]:8080
2018-10-26 16:40:52,282 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
2018-10-26 16:40:52,285 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: Thorntail 2.2.0.Final (WildFly Core 3.0.8.Final) started in 5331ms - Started 143 of 161 services (32 services are lazy, passive or on-demand)
2018-10-26 16:40:52,789 INFO  [org.wildfly.swarm.runtime.deployer] (main) deploying demo.war
2018-10-26 16:40:52,839 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0027: Starting deployment of "demo.war" (runtime-name: "demo.war")
2018-10-26 16:40:53,364 WARN  [org.jboss.as.dependency.private] (MSC service thread 1-3) WFLYSRV0018: Deployment "deployment.demo.war" is using a private module ("org.jboss.jts") which may be changed or removed in future versions without notice.
2018-10-26 16:40:53,364 WARN  [org.jboss.as.dependency.private] (MSC service thread 1-3) WFLYSRV0018: Deployment "deployment.demo.war" is using a private module ("org.jboss.ironjacamar.jdbcadapters") which may be changed or removed in future versions without notice.
2018-10-26 16:40:53,365 WARN  [org.jboss.as.dependency.private] (MSC service thread 1-3) WFLYSRV0018: Deployment "deployment.demo.war" is using a private module ("org.jboss.jts") which may be changed or removed in future versions without notice.
2018-10-26 16:40:53,365 WARN  [org.jboss.as.dependency.private] (MSC service thread 1-3) WFLYSRV0018: Deployment "deployment.demo.war" is using a private module ("org.jboss.ironjacamar.jdbcadapters") which may be changed or removed in future versions without notice.
2018-10-26 16:40:53,645 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) WFLYUT0018: Host default-host starting
2018-10-26 16:40:54,005 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 12) RESTEASY002225: Deploying javax.ws.rs.core.Application: class com.dave.demothorntail.rest.RestApplication
2018-10-26 16:40:54,036 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 12) WFLYUT0021: Registered web context: '/' for server 'default-server'
2018-10-26 16:40:54,200 INFO  [org.jboss.as.server] (main) WFLYSRV0010: Deployed "demo.war" (runtime-name : "demo.war")
2018-10-26 16:40:54,216 INFO  [org.wildfly.swarm] (main) THORN99999: Thorntail is Ready




Check the project

http://localhost:8080/hello

Wednesday, November 2, 2016

Run Docker JBoss Wildfly image on AWS ECS

Install Docker on AWS ECS
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html


       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2016.09-release-notes/
[ec2-user@ip-172-31-31-199 ~]$ sudo yum update -y
Loaded plugins: priorities, update-motd, upgrade-helper
No packages marked for update
[ec2-user@ip-172-31-31-199 ~]$  sudo yum install -y docker
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 0:1.11.2-1.6.amzn1 will be installed
--> Processing Dependency: xfsprogs for package: docker-1.11.2-1.6.amzn1.x86_64
--> Running transaction check
---> Package xfsprogs.x86_64 0:3.2.2-2.20.amzn1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch          Version                   Repository        Size
================================================================================
Installing:
 docker          x86_64        1.11.2-1.6.amzn1          amzn-main         17 M
Installing for dependencies:
 xfsprogs        x86_64        3.2.2-2.20.amzn1          amzn-main        1.7 M

Transaction Summary
================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 18 M
Installed size: 59 M
Downloading packages:
(1/2): docker-1.11.2-1.6.amzn1.x86_64.rpm                |  17 MB     00:00     
(2/2): xfsprogs-3.2.2-2.20.amzn1.x86_64.rpm              | 1.7 MB     00:00     
--------------------------------------------------------------------------------
Total                                               21 MB/s |  18 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : xfsprogs-3.2.2-2.20.amzn1.x86_64                             1/2 
  Installing : docker-1.11.2-1.6.amzn1.x86_64                                                        2/2 
  Verifying  : docker-1.11.2-1.6.amzn1.x86_64                                                        1/2 
  Verifying  : xfsprogs-3.2.2-2.20.amzn1.x86_64                                                      2/2 

Installed:
  docker.x86_64 0:1.11.2-1.6.amzn1                                                                       

Dependency Installed:
  xfsprogs.x86_64 0:3.2.2-2.20.amzn1                                                                     

Complete!
[ec2-user@ip-172-31-31-199 ~]$ sudo service docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:    .                                  [  OK  ]
[ec2-user@ip-172-31-31-199 ~]$ sudo usermod -a -G docker ec2-user
[ec2-user@ip-172-31-31-199 ~]$ 

Verify Docker status

[ec2-user@ip-172-31-31-199 ~]$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.11.2
Storage Driver: devicemapper
 Pool Name: docker-202:1-394626-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 11.8 MB
 Data Space Total: 107.4 GB
 Data Space Available: 7.223 GB
 Metadata Space Used: 581.6 kB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.147 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.93-RHEL7 (2015-01-28)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: null host bridge
Kernel Version: 4.4.23-31.54.amzn1.x86_64
Operating System: Amazon Linux AMI 2016.09
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.4 MiB
Name: ip-172-31-31-199
ID: IEGJ:BLTG:7DGR:PNN7:SDZS:3M7H:L6LR:CB3M:52IV:SG2R:O3KF:NZPI
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): false
Registry: https://index.docker.io/v1/
[ec2-user@ip-172-31-31-199 ~]$ 


Run JBoss Wildfly Docker image

[ec2-user@ip-172-31-31-199 ~]$ docker run -it -p 8080:8080 jboss/wildfly 
=========================================================================

  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

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

21:14:22,924 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final
21:14:23,279 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
21:14:23,368 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting


List Docker processes

[ec2-user@ip-172-31-31-199 ~]$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
0a5959e5cd9e        jboss/wildfly       "/opt/jboss/wildfly/b"   9 minutes ago       Up 9 minutes        0.0.0.0:8080->8080/tcp   adoring_allen


Connect to Wildfly with links browser from other shell

Install links and connect to http:localhost:8080



[ec2-user@ip-172-31-31-199 ~]$ yum install links

[ec2-user@ip-172-31-31-199 ~]$ links http://localhost:8080




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