jboss eap

Deploying a Binary WAR File to Openshift 4 Using s2i

We can leverage s2i to deploy an existing war file into Openshift 4. How to do it is pretty much simple and straight forward, basically just running some oc command and you can have your war file deployed on Openshift.

But before we go far, we need to have a sample application to be deployed and for this sample, i have a hello world apps which is created by using Java Servlet.

https://github.com/edwin/jboss-eap-hello-world

We can clone this application, and build it using a simple maven command.

$ mvn clean package

Next step is create an empty folder where we would run our oc command,

$ mkdir -p jboss-eap/deployments

and we can put our ROOT.war file inside deployment folder,

$ tree .
.
+---- deployments
    +---- ROOT.war

Next is creating a new BuildConfig,

$ oc new-build --name=custom-eap-application \
	--binary=true --image-stream=jboss-eap74-openjdk11-openshift:latest

and start building it by using a start-build command, we can also repeat this step again if there is a new changes to our war file

$ oc start-build custom-eap-application --from-dir . --follow

and finally we can deploy our application directly by using new-app command,

$ oc new-app --name=custom-eap-application \ 
	--image-stream=edwin-ns/custom-eap-application:latest

So deployment can be done easily by using just 3 simple steps.

XA-Datasource Configuration for MySql

This is the configuration that is needed when deploying MySql XA Datasource connection on JBoss EAP

<xa-datasource jndi-name="java:jboss/datasources/mysqlXADS" pool-name="mysqlXADS">
	<driver>mysql</driver>
	<xa-datasource-property name="ServerName">localhost</xa-datasource-property>
	<xa-datasource-property name="DatabaseName">db_test</xa-datasource-property>
	<security>
	  <user-name>root</user-name>
	  <password>password</password>
	</security>
	<validation>
	  <valid-connection-checker 
		   class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker">
	  </valid-connection-checker>
	  <exception-sorter 
		   class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter">
	  </exception-sorter>
	</validation>
</xa-datasource>

<drivers>
	<driver name="mysql" module="com.mysql">
		<xa-datasource-class>com.mysql.cj.jdbc.MysqlXADataSource</xa-datasource-class>		
	</driver>			
</drivers>

Dockerfile for Deploying Applications in JBoss EAP 7.4, and on top of Openshift 4

Openshift have a different permission right because by default, any containers deployed in Openshift will gets a random user ID. Therefore it needs a specific approach when creating a containerized apps, especially in regards to folder access rights. A simple chmod or chown commands wont be sufficient enough for this purpose.

Long story short, we can use below Dockerfile to be use to deploy an existing war file into JBoss EAP base image and push the result into Openshift 4.

FROM registry.redhat.io/jboss-eap-7/eap74-openjdk11-openshift-rhel8

ENV DISABLE_EMBEDDED_JMS_BROKER=true

COPY target/*.war $JBOSS_HOME/standalone/deployments/

USER root
RUN chgrp -R 0 $JBOSS_HOME/standalone/deployments/ && \
	chmod -R g=u $JBOSS_HOME/standalone/deployments/
USER 185

EXPOSE 8080

Run below command to build the image, can use either Podman or Docker command for it.

$ podman build -t custom-app-name .