In this tutorial Java EE example application on Openshift we have deployed a sample Java EE application using a database on Openshift. We will explore now other possibilities such as providing a custom application server configuration, a set of custom modules and finally we will learn how to add artifacts directly into the deployments folder of the application server.

Starting WildFly on Openshift with a custom configuration

So our first project will show how to provide a custom configuration for a WildFly image. Here is the project: https://github.com/fmarchioni/mastertheboss/tree/master/openshift/config

As you can see from the following picture, the custom configuration has to be placed in a cfg folder:

How to customize WildFly applications on Openshift

In our case, the custom configuration merely adds a System property that will be inspected by the application placed in the "src" folder:

<system-properties>
     <property name="greeting" value="Hello World"/>
</system-properties>

In order to build the application on Openshift specify the root folder as Git Repository URL: https://github.com/fmarchioni/mastertheboss

Next, specify the subfolder "openshift/config" as path:

How to customize WildFly applications on Openshift

Once the application has been built, in the top header of the page it will be displayed the System Property gathered from the custom configuration:

How to customize WildFly applications on Openshift

Adding custom modules and deployments to WildFly on Openshift

Our second application, available on github at https://github.com/fmarchioni/mastertheboss/tree/master/openshift/module, will show how to add external modules and deployments during the Source to Image process.

How to customize WildFly applications on Openshift

As you can see from the above picture, you can use the following folders:

  • modules: Place here modules just like you would do in a bare-metal installation of WildFly. They will be automatically uploaded on WildFly
  • deployments: Place here artifacts that are to be deployed on the application server.
├── modules
│   └── com
│       └── itext
│           └── main
│               ├── itext-5.0.5.jar
│               └── module.xml
├── pom.xml
├── README.md
└── src
    └── main
        ├── java
        │   └── com
        │       └── mastertheboss
        │           └── CreatePDFExample.java
        └── webapp
            ├── index.jsp
            └── WEB-INF
                ├── jboss-deployment-structure.xml
                └── web.xml

The module.xml loads the itext JAR file and uploads it into the application server.

<module xmlns="urn:jboss:module:1.1" name="com.itext">

    <properties>
        <property name="jboss.api" value="private"/>
    </properties>

      <resources>
        <resource-root path="itext-5.0.5.jar"/> 
    </resources>

</module>

In order to link the library with the application server add a jboss-deployment-structure.xml file:

<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="com.itext" />
    </dependencies>
    </deployment>
</jboss-deployment-structure>

To build the application on Openshift specify the root folder as Git Repository URL: https://github.com/fmarchioni/mastertheboss

Next, specify the subfolder "openshift/modules" as path:

How to customize WildFly applications on Openshift

Here is the application in action:

How to customize WildFly applications on Openshift

That's all. You can check the rest of the source code on Github: https://github.com/fmarchioni/mastertheboss/tree/master/openshift/module

0
0
0
s2smodern

Related articles available on mastertheboss.com

Openshift installation quick tutorial

IMPORTANT: This tutorial is now outdated. Openishift origin has b

Java EE example application on Openshift

In this tutorial we will learn how to deploy a Java EE applicatio

Running tomcat Docker image on Openshift

A common issue when porting Docker images on Openshift is that th

Deploy Docker images on Openshift

This tutorial will teach you how you can build and deploy a custo

Using Property files in your Openshift applications

A common need for most application is to store its configuration

Accessing Openshift services remotely

In this article we will learn how to connect to services running