Red Hat JBoss Web Server for OpenShift
Installing and using Red Hat JBoss Web Server for OpenShift
Abstract
Providing feedback on Red Hat JBoss Web Server documentation Copy linkLink copied to clipboard!
To report an error or to improve our documentation, log in to your Red Hat Jira account and submit an issue. If you do not have a Red Hat Jira account, then you will be prompted to create an account.
Procedure
- Click the following link to create a ticket.
- Enter a brief description of the issue in the Summary.
- Provide a detailed description of the issue or enhancement in the Description. Include a URL to where the issue occurs in the documentation.
- Clicking Submit creates and routes the issue to the appropriate documentation team.
Making open source more inclusive Copy linkLink copied to clipboard!
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.
Chapter 1. Red Hat JBoss Web Server for OpenShift Copy linkLink copied to clipboard!
The Apache Tomcat 9 component of Red Hat JBoss Web Server (JWS) 5.7 is available as a containerized image that is designed for Red Hat OpenShift. You can use this image to build, scale, and test Java web applications for deployment across hybrid cloud environments.
1.1. Differences between Red Hat JBoss Web Server and JWS for OpenShift Copy linkLink copied to clipboard!
JWS for OpenShift images are different from a regular release of Red Hat JBoss Web Server.
Consider the following differences between the JWS for OpenShift images and a standard JBoss Web Server deployment:
-
In a JWS for OpenShift image, the
/opt/jws-5.7/directory is the location ofJWS_HOME. -
In a JWS for OpenShift deployment, all load balancing is handled by the OpenShift router rather than the JBoss Core Services
mod_clusterconnector ormod_jkconnector.
1.2. OpenShift image version compatibility and support Copy linkLink copied to clipboard!
OpenShift images are tested with different operating system versions, configurations and interface points that represent the most common combination of technologies that Red Hat OpenShift Container Platform customers are using.
When you want to deploy new applications, you must use the 5.7 version of JWS for OpenShift images and application templates.
The 5.6 version of JWS for OpenShift images and application templates are deprecated and no longer receive updates.
1.3. Supported architectures for JBoss Web Server Copy linkLink copied to clipboard!
JBoss Web Server supports the following architectures:
- x86_64 (AMD64)
- IBM Z (s390x) in the OpenShift environment
- IBM Power (ppc64le) in the OpenShift environment
You can use the JBoss Web Server image for OpenJDK 11 or OpenJDK 17 with all supported architectures. For more information about images, see the Red Hat Container Catalog.
1.4. Health checks for Red Hat container images Copy linkLink copied to clipboard!
All OpenShift Container Platform images have a health rating associated with them. You can find the health rating for Red Hat JBoss Web Server by navigating to the Certfied container images page, and then search for JBoss Web Server and select the 5.7 version.
You can also perform health checks on an OpenShift container to test the container for liveliness and readiness.
Chapter 2. Getting started with Red Hat JBoss Web Server for OpenShift Copy linkLink copied to clipboard!
You can import the latest Red Hat JBoss Web Server for OpenShift image streams and templates from the Red Hat container registry. You can subsequently use the JWS for OpenShift Source-to-Image (S2I) process to create JBoss Web Server for OpenShift applications by using existing maven binaries or from source code.
Before you follow the instructions in this document, you must ensure that an OpenShift cluster is already installed and configured as a prerequisite. For more information about installing and configuring OpenShift clusters, see the OpenShift Container Platform Installing guide.
The JWS for OpenShift application templates are distributed for Tomcat 9.
2.1. Configuring an authentication token for the Red Hat Container Registry Copy linkLink copied to clipboard!
Before you can import and use a Red Hat JBoss Web Server for OpenShift image, you must first ensure that you have configured an authentication token to access the Red Hat Container Registry.
You can create an authentication token by using a registry service account. This means that you do not have to use or store your Red Hat account username and password in your OpenShift configuration.
Procedure
- Follow the instructions on the Red Hat Customer Portal to create an authentication token using a registry service account.
- On the Token Information page for your token, click the OpenShift Secret tab and download the YAML file that contains the OpenShift secret for the token.
Use the YAML file that you have downloaded to create the authentication token secret for your OpenShift project.
For example:
oc create -f 1234567_myserviceaccount-secret.yaml
oc create -f 1234567_myserviceaccount-secret.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow To configure the secret for your OpenShift project, enter the following commands:
oc secrets link default 1234567-myserviceaccount-pull-secret --for=pull oc secrets link builder 1234567-myserviceaccount-pull-secret --for=pull
oc secrets link default 1234567-myserviceaccount-pull-secret --for=pull oc secrets link builder 1234567-myserviceaccount-pull-secret --for=pullCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding examples, replace
1234567-myserviceaccountwith the name of the secret that you created in the previous step.
2.2. Importing JBoss Web Server image streams and templates Copy linkLink copied to clipboard!
You can import Red Hat JBoss Web Server for OpenShift image streams and templates from the Red Hat Container Registry. You must import the latest JBoss Web Server image streams and templates for your JDK into the namespace of your OpenShift project.
Prerequisites
Procedure
- Log in to the Red Hat Container Registry by using your Customer Portal credentials. For more information, see Red Hat Container Registry Authentication.
Depending on the JDK version that you are using, perform one of the following steps:
OpenJDK 8
If you are using OpenJDK 8, enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command imports the UBI8 JDK 8 image stream,
jboss-webserver57-openjdk8-tomcat9-openshift-ubi8, and all templates specified in the command.OpenJDK 11
If you are using OpenJDK 11, enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command imports the UBI8 JDK 11 image stream,
jboss-webserver57-openjdk11-tomcat9-openshift-ubi8, and all templates specified in the command.OpenJDK 17
If you are using OpenJDK 17, enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command imports the UBI8 JDK 17 image stream,
jboss-webserver57-openjdk17-tomcat9-openshift-ubi8, and all templates specified in the command.
In the preceding commands, ensure that you specify the latest release of JBoss Web Server 5.7 that you want to import (for example, 5.7.8).
2.3. Importing the latest JWS for OpenShift image Copy linkLink copied to clipboard!
You can import the latest available JWS for OpenShift image by using the import-image command. Red Hat provides separate JWS for OpenShift images for OpenJDK 8, OpenJDK 11, and OpenJDK 17.
Prerequisites
- You are logged in to the Red Hat Container Registry.
- You have imported image streams and templates.
Procedure
Depending on the JDK version that you are using, perform one of the following steps:
To update the core JBoss Web Server 5.7 tomcat 9 with OpenJDK 8 OpenShift image, enter the following command:
oc -n openshift import-image \ jboss-webserver57-openjdk8-tomcat9-openshift-ubi8:5.7.8
$ oc -n openshift import-image \ jboss-webserver57-openjdk8-tomcat9-openshift-ubi8:5.7.8Copy to Clipboard Copied! Toggle word wrap Toggle overflow To update the core JBoss Web Server 5.7 tomcat 9 with OpenJDK 11 OpenShift image, enter the following command:
oc -n openshift import-image \ jboss-webserver57-openjdk11-tomcat9-openshift-ubi8:5.7.8
$ oc -n openshift import-image \ jboss-webserver57-openjdk11-tomcat9-openshift-ubi8:5.7.8Copy to Clipboard Copied! Toggle word wrap Toggle overflow To update the core JBoss Web Server 5.7 tomcat 9 with OpenJDK 17 OpenShift image, enter the following command:
oc -n openshift import-image \ jboss-webserver57-openjdk17-tomcat9-openshift-ubi8:5.7.8
$ oc -n openshift import-image \ jboss-webserver57-openjdk17-tomcat9-openshift-ubi8:5.7.8Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The 5.7.8 tag at the end of each image you import refers to the stream version that is set in the image stream.
2.4. JWS for OpenShift S2I process Copy linkLink copied to clipboard!
You can run and configure the JWS for OpenShift images by using the OpenShift source-to-image (S2I) process with the application template parameters and environment variables.
The S2I process for the JWS for OpenShift images works as follows:
-
If the
configurationsource directory contains a Mavensettings.xmlfile, thesettings.xmlfile is moved to the$HOME/.m2/directory of the new image. If the source repository contains a
pom.xmlfile, a Maven build is triggered using the contents of the$MAVEN_ARGSenvironment variable.By default, the
packagegoal is used with theopenshiftprofile, which includes the-DskipTestsargument to skip tests, and the-Dcom.redhat.xpaas.repo.redhatgaargument to enable the Red Hat GA repository.The results of a successful Maven build are copied to the
/opt/jws-5.7/tomcat/webappsdirectory. This includes all WAR files from the source directory that is specified by the$ARTIFACT_DIRenvironment variable. The default value of$ARTIFACT_DIRis thetarget/directory.You can use the
$MAVEN_ARGS_APPENDenvironment variable to modify the Maven arguments.-
All WAR files from the
deploymentssource directory are copied to the/opt/jws-5.7/tomcat/webappsdirectory. -
All files in the
configurationsource directory are copied to the/opt/jws-5.7/tomcat/conf/directory, excluding the Maven settings.xml file. All files in the
libsource directory are copied to the/opt/jws-5.7/tomcat/lib/directory.NoteIf you want to use custom Tomcat configuration files, use the same file names that are used for a normal Tomcat installation such as
context.xmlandserver.xml.
For more information about configuring the S2I process to use a custom Maven artifacts repository mirror, see Maven artifact repository mirrors and JWS for OpenShift.
2.5. Creating a JWS for OpenShift application by using existing Maven binaries Copy linkLink copied to clipboard!
You can create a JWS for OpenShift application by using existing Maven binaries. You can use the oc start-build command to deploy existing applications on OpenShift.
This procedure shows how to create an example application that is based on the tomcat-websocket-chat quickstart example.
Prerequisites
You have an existing
.war,.ear, or.jarfile for the application that you want to deploy on JWS for OpenShift or you have built the application locally.For example, to build the
tomcat-websocket-chatapplication locally, perform the following steps:To clone the source code, enter the following command:
git clone https://github.com/web-servers/tomcat-websocket-chat-quickstart.git
$ git clone https://github.com/web-servers/tomcat-websocket-chat-quickstart.gitCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Red Hat JBoss Middleware Maven repository, as described in Configure the Red Hat JBoss Middleware Maven Repository.
For more information about the Maven repository, see the Red Hat JBoss Enerprise Maven Repository web page.
To build the application, enter the following commands:
cd tomcat-websocket-chat-quickstart/tomcat-websocket-chat/ mvn clean package
$ cd tomcat-websocket-chat-quickstart/tomcat-websocket-chat/ $ mvn clean packageCopy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command produces the following output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
On your local file system, create a source directory for the binary build and a
deploymentssubdirectory.For example, to create a
/ocpsource directory and a/deploymentssubdirectory for thetomcat-websocket-chatapplication, enter the following commands:cd tomcat-websocket-chat-quickstart/tomcat-websocket-chat/ mkdir -p ocp/deployments
$ cd tomcat-websocket-chat-quickstart/tomcat-websocket-chat/ $ mkdir -p ocp/deploymentsCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe source directory can contain any content required by your application that is not included in the Maven binary. For more information, see JWS for OpenShift S2I process.
Copy the
.war,.ear, or.jarbinary files to thedeploymentssubdirectory.For example, to copy the
.warfile for the example tomcat-websocket-chat application, enter the following command:cp target/websocket-chat.war ocp/deployments/
$ cp target/websocket-chat.war ocp/deployments/Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding example,
target/websocket-chat.waris the path to the binary file you want to copy.Application archives in the
deploymentssubdirectory of the source directory are copied to the$JWS_HOME/tomcat/webapps/directory of the image that is being built on OpenShift. To allow the application to be deployed successfully, you must ensure that the directory hierarchy that contains the web application data is structured correctly. For more information, see JWS for OpenShift S2I process.Log in to the OpenShift instance:
oc login <url>
$ oc login <url>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new project if required.
For example:
oc new-project jws-bin-demo
$ oc new-project jws-bin-demoCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding example,
jws-bin-demois the name of the project you want to create.Identify the JWS for OpenShift image stream to use for your application:
oc get is -n openshift | grep ^jboss-webserver | cut -f1 -d ' '
$ oc get is -n openshift | grep ^jboss-webserver | cut -f1 -d ' 'Copy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command produces the following type of output:
jboss-webserver57-openjdk8-tomcat9-openshift-ubi8
jboss-webserver57-openjdk8-tomcat9-openshift-ubi8Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe
-n openshiftoption specifies the project to use. Theoc get is -n openshiftcommand gets the image stream resources from theopenshiftproject.Create the new build configuration, and ensure that you specify the image stream and application name.
For example, to create the new build configuration for the example tomcat-websocket-chat application:
oc new-build --binary=true \ --image-stream=jboss-webserver57-openjdk8-tomcat9-openshift-ubi8:latest \ --name=jws-wsch-app
$ oc new-build --binary=true \ --image-stream=jboss-webserver57-openjdk8-tomcat9-openshift-ubi8:latest \ --name=jws-wsch-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding example,
jws-wsch-appis the name of the JWS for OpenShift application.The preceding command produces the following type of output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start the binary build.
For example:
oc start-build jws-wsch-app --from-dir=./ocp --follow
$ oc start-build jws-wsch-app --from-dir=./ocp --followCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding example,
jws-wsch-appis the name of the JWS for OpenShift application, andocpis the name of the source directory.The preceding command instructs OpenShift to use the source directory that you have created for binary input of the OpenShift image build.
The preceding command produces the following type of output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new OpenShift application based on the image:
For example:
oc new-app jws-wsch-app
$ oc new-app jws-wsch-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding example,
jws-wsch-appis the name of the JWS for OpenShift application.The preceding command produces the following type of output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Expose the service to make the application accessible to users:
For example, to make the example
jws-wsch-appapplication accessible, perform the following steps:Check the name of the service to expose:
oc get svc -o name
$ oc get svc -o nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command produces the following type of output:
service/jws-wsch-app
service/jws-wsch-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow Expose the service:
oc expose svc/jws-wsch-app
$ oc expose svc/jws-wsch-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command produces the following type of output:
route "jws-wsch-app" exposed
route "jws-wsch-app" exposedCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Retrieve the address of the exposed route:
oc get routes --no-headers -o custom-columns='host:spec.host' jws-wsch-app
oc get routes --no-headers -o custom-columns='host:spec.host' jws-wsch-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open a web browser and enter the URL to access the application.
For example, to access the example
jws-wsch-appapplication, enter the following URL:http://<address_of_exposed_route>/websocket-chatNoteIn the preceding example, replace
<address_of_exposed_route>with the appropriate value for your deployment.
2.6. Creating a JWS for OpenShift application from source code Copy linkLink copied to clipboard!
You can create a JWS for OpenShift application from source code.
For detailed information about creating new OpenShift applications from source code, see OpenShift.com - Creating an application from source code.
Prerequisites
- The application data is structured correctly. For more information, see JWS for OpenShift S2I process.
Procedure
Log in to the OpenShift instance:
oc login <url>
$ oc login <url>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new project if required:
oc new-project <project-name>
$ oc new-project <project-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding example, replace
<project-name>with the name of the project you want to create.Identify the JWS for OpenShift image stream to use for your application:
oc get is -n openshift | grep ^jboss-webserver | cut -f1 -d ' '
$ oc get is -n openshift | grep ^jboss-webserver | cut -f1 -d ' 'Copy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command produces the following type of output:
jboss-webserver57-openjdk8-tomcat9-openshift-ubi8
jboss-webserver57-openjdk8-tomcat9-openshift-ubi8Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe
-n openshiftoption specifies the project to use. Theoc get is -n openshiftcommand gets the image stream resources from theopenshiftproject.Create the new OpenShift application from source code by using Red Hat JBoss Web Server for OpenShift images:
oc new-app \ <source_code_location> \ --image-stream=jboss-webserver57-openjdk8-tomcat9-openshift-ubi8:latest \ --name=<openshift_application_name>
$ oc new-app \ <source_code_location> \ --image-stream=jboss-webserver57-openjdk8-tomcat9-openshift-ubi8:latest \ --name=<openshift_application_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc new-app \ https://github.com/web-servers/tomcat-websocket-chat-quickstart.git#main \ --image-stream=jboss-webserver57-openjdk8-tomcat9-openshift-ubi8:latest \ --context-dir='tomcat-websocket-chat' \ --name=jws-wsch-app
$ oc new-app \ https://github.com/web-servers/tomcat-websocket-chat-quickstart.git#main \ --image-stream=jboss-webserver57-openjdk8-tomcat9-openshift-ubi8:latest \ --context-dir='tomcat-websocket-chat' \ --name=jws-wsch-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command adds the source code to the image and compiles the source code. The preceding command also creates the build configuration and services.
To expose the application, perform the following steps:
To check the name of the service to expose:
oc get svc -o name
$ oc get svc -o nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command produces the following type of output:
service/<openshift_application_name>
service/<openshift_application_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow To expose the service:
oc expose svc/<openshift_application_name>
$ oc expose svc/<openshift_application_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command produces the following type of output:
route "<openshift_application_name>" exposed
route "<openshift_application_name>" exposedCopy to Clipboard Copied! Toggle word wrap Toggle overflow
To retrieve the address of the exposed route:
oc get routes --no-headers -o custom-columns='host:spec.host' <openshift_application_name>
oc get routes --no-headers -o custom-columns='host:spec.host' <openshift_application_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Open a web browser and enter the following URL to access the application:
http://<address_of_exposed_route>/<java_application_name>NoteIn the preceding example, replace
<address_of_exposed_route>and<java_application_name>with appropriate values for your deployment.
2.7. Adding additional JAR files in the tomcat/lib directory Copy linkLink copied to clipboard!
You can use Docker to add additional Java Archive (JAR) files in the tomcat/lib directory.
Procedure
Start the image in Docker:
docker run --network host -i -t -p 8080:8080 ImageURL
docker run --network host -i -t -p 8080:8080 ImageURLCopy to Clipboard Copied! Toggle word wrap Toggle overflow Find the
CONTAINER ID:docker ps | grep <ImageName>
docker ps | grep <ImageName>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the library to the
tomcat/lib/directory:docker cp <yourLibrary> <CONTAINER ID>:/opt/jws-5.7/tomcat/lib/
docker cp <yourLibrary> <CONTAINER ID>:/opt/jws-5.7/tomcat/lib/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Commit the changes to a new image:
docker commit <CONTAINER ID> <NEW IMAGE NAME>
docker commit <CONTAINER ID> <NEW IMAGE NAME>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new image tag:
docker tag <NEW IMAGE NAME>:latest <NEW IMAGE REGISTRY URL>:<TAG>
docker tag <NEW IMAGE NAME>:latest <NEW IMAGE REGISTRY URL>:<TAG>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Push the image to a registry:
docker push <NEW IMAGE REGISTRY URL>
docker push <NEW IMAGE REGISTRY URL>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 3. Red Hat JBoss Web Server metering labels for Red Hat OpenShift Copy linkLink copied to clipboard!
You can add metering labels to your Red Hat JBoss Web Server pods and check Red Hat subscription details with the OpenShift Metering Operator.
- Do not add metering labels to any pods that an operator or a template deploys and manages.
- You can apply labels to pods using the Metering Operator on OpenShift Container Platform version 4.8 and earlier. From version 4.9 onward, the Metering Operator is no longer available without a direct replacement.
Red Hat JBoss Web Server can use the following metering labels:
-
com.company: Red_Hat -
rht.prod_name: Red_Hat_Runtimes -
rht.prod_ver: 2022-Q4 -
rht.comp: JBoss_Web_Server -
rht.comp_ver: 5.7.0 -
rht.subcomp: Tomcat 9 -
rht.subcomp_t: application
Appendix A. S2I scripts and Maven Copy linkLink copied to clipboard!
The Red Hat JBoss Web Server for OpenShift image includes S2I scripts and Maven.
A.1. Maven artifact repository mirrors and JWS for OpenShift Copy linkLink copied to clipboard!
A Maven repository holds build artifacts and dependencies, such as the project Java archive (JAR) files, library JAR files, plugins or any other project-specific artifacts. A Maven repository also defines locations that you can download artifacts from while performing the source-to-image (S2I) build. In addition to using the Maven Central Repository, some organizations also deploy a local custom repository (mirror).
A local mirror provides the following benefits:
- Availability of a synchronized mirror that is geographically closer and faster
- Greater control over the repository content
- Possibility to share artifacts across different teams (developers and continuous integration (CI)) without relying on public servers and repositories
- Improved build times
A Maven repository manager can serve as local cache to a mirror. If the repository manager is already deployed and can be reached externally at a specified URL location, the S2I build can use this repository. You can use an internal Maven repository by adding the MAVEN_MIRROR_URL environment variable to the build configuration of the application.
A.1.1. Using an internal Maven repository for a new build configuration Copy linkLink copied to clipboard!
You can add the MAVEN_MIRROR_URL environment variable to a new build configuration of your application, by specifying the --build-env option with the oc new-app command or the oc new-build command.
Procedure
Enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe preceding command assumes that the repository manager is already deployed and can be reached at
http://10.0.0.1:8080/repository/internal/.
A.1.2. Using an internal Maven repository for an existing build configuration Copy linkLink copied to clipboard!
You can add the MAVEN_MIRROR_URL environment variable to an existing build configuration of your application, by specifying the name of the build configuration with the oc set env command.
Procedure
Identify the build configuration that requires the
MAVEN_MIRROR_URLvariable:oc get bc -o name
$ oc get bc -o nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding command produces the following type of output:
buildconfig/jws
buildconfig/jwsCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding example, jws is the name of the build configuration.
Add the
MAVEN_MIRROR_URLenvironment variable tobuildconfig/jws:oc set env bc/jws MAVEN_MIRROR_URL="http://10.0.0.1:8080/repository/internal/"
$ oc set env bc/jws MAVEN_MIRROR_URL="http://10.0.0.1:8080/repository/internal/" buildconfig "jws" updatedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the build configuration has updated:
oc set env bc/jws --list buildconfigs jws
$ oc set env bc/jws --list # buildconfigs jws MAVEN_MIRROR_URL=http://10.0.0.1:8080/repository/internal/Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Schedule a new build of the application by using
oc start-build
During the application build process, Maven dependencies are downloaded from the repository manager rather than from the default public repositories. When the build process is completed, the mirror contains all the dependencies that are retrieved and used during the build process.
A.2. Scripts included on the Red Hat JBoss Web Server for OpenShift image Copy linkLink copied to clipboard!
The Red Hat JBoss Web Server for OpenShift image includes scripts to run Catalina and to use Maven to create and deploy the .war package.
run- Runs Catalina (Tomcat)
assemble-
Uses Maven to build the web application source, create the
.warfile, and move the.warfile to the$JWS_HOME/tomcat/webappsdirectory.
A.3. JWS for OpenShift datasources Copy linkLink copied to clipboard!
JWS for OpenShift provides three type of data sources:
- Default internal data sources
-
PostgreSQL, MySQL, and MongoDB data sources are available on OpenShift by default through the Red Hat Registry. These data sources do not require additional environment files to be configured for image streams. To enable a database to be discovered and used as a data source, you can set the
DB_SERVICE_PREFIX_MAPPINGenvironment variable to the name of the OpenShift service. - Other internal data sources
- These data sources are run on OpenShift but they are not available by default through the Red Hat Registry. Environment files that are added to OpenShift Secrets provide configuration of other internal data sources.
- External data sources
- These data sources are not run on OpenShift. Environment files that are added to OpenShift Secrets provide configuration of external data sources.
ENV_FILES property
You can add the environment variables for data sources to the OpenShift Secret for the project. You can use the ENV_FILES property to call these environment files within the template.
DB_SERVICE_PREFIX_MAPPING environment variable
Data sources are automatically created based on the value of certain environment variables. The DB_SERVICE_PREFIX_MAPPING environment variable defines JNDI mappings for the data sources.
The allowed value for the DB_SERVICE_PREFIX_MAPPING variable is a comma-separated list of POOLNAME-DATABASETYPE=PREFIX triplets. Each triplet consists of the following values:
-
POOLNAMEis used as thepool-namein the data source. -
DATABASETYPEis the database driver to use. -
PREFIXis the prefix in the names of environment variables that are used to configure the data source.
For each POOLNAME-DATABASETYPE=PREFIX triplet that is defined in the DB_SERVICE_PREFIX_MAPPING environment variable, the launch script creates a separate data source, which is executed when running the image.
A.4. JWS for OpenShift compatible environment variables Copy linkLink copied to clipboard!
You can modify the build configuration by including environment variables with the source-to-image (S2I) build command. For more information, see Maven artifact repository mirrors and JWS for OpenShift.
The following table lists the valid environment variables for the Red Hat JBoss Web Server for OpenShift images:
| Variable Name | Display Name | Description | Example Value |
|---|---|---|---|
| ARTIFACT_DIR | N/A |
| target |
| APPLICATION_NAME | Application Name | The name for the application | jws-app |
| CONTEXT_DIR | Context Directory | Path within Git project to build; empty for root project directory | tomcat-websocket-chat |
| GITHUB_WEBHOOK_SECRET | Github Webhook Secret | Github trigger secret | Expression from: [a-zA-Z0-9]{8} |
| GENERIC_WEBHOOK_SECRET | Generic Webhook Secret | Generic build trigger secret | Expression from: [a-zA-Z0-9]{8} |
| HOSTNAME_HTTP | Custom HTTP Route Hostname | Custom hostname for http service route. Leave blank for default hostname | <application-name>-<project>.<default-domain-suffix> |
| HOSTNAME_HTTPS | Custom HTTPS Route Hostname | Custom hostname for https service route. Leave blank for default hostname | <application-name>-<project>.<default-domain-suffix> |
| IMAGE_STREAM_NAMESPACE | Imagestream Namespace | Namespace in which the ImageStreams for Red Hat Middleware images are installed | openshift |
| JWS_HTTPS_SECRET | Secret Name | The name of the secret containing the certificate files | jws-app-secret |
| JWS_HTTPS_CERTIFICATE | Certificate Name | The name of the certificate file within the secret | server.crt |
| JWS_HTTPS_CERTIFICATE_KEY | Certificate Key Name | The name of the certificate key file within the secret | server.key |
| JWS_HTTPS_CERTIFICATE_PASSWORD | Certificate Password | The Certificate Password | P5ssw0rd |
| SOURCE_REPOSITORY_URL | Git Repository URL | Git source URI for Application | https://github.com/web-servers/tomcat-websocket-chat-quickstart.git |
| SOURCE_REPOSITORY_REFERENCE | Git Reference | Git branch/tag reference | 1.2 |
| IMAGE_STREAM_NAMESPACE | Imagestream Namespace | Namespace in which the ImageStreams for Red Hat Middleware images are installed | openshift |
| MAVEN_MIRROR_URL | Maven Mirror URL | URL of a Maven mirror/repository manager to configure. | http://10.0.0.1:8080/repository/internal/ |
Appendix B. Valves on JWS for OpenShift Copy linkLink copied to clipboard!
You can define the following environment variable to insert the valve component into the request processing pipeline for the associated Catalina container.
| Variable Name | Description | Example Value | Default Value |
|---|---|---|---|
| ENABLE_ACCESS_LOG | Enable the Access Log Valve to log access messages to the standard output channel. | true | false |
Appendix C. Checking OpenShift logs Copy linkLink copied to clipboard!
You can use the oc logs command to view the OpenShift logs or the logs that the console provides for a running container.
Procedure
Enter the following command:
oc logs -f <pod_name> <container_name>
$ oc logs -f <pod_name> <container_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding command, replace
<pod_name>and<container_name>with appropriate values for your deployment.Access logs are stored in the
/opt/jws-5.7/tomcat/logs/directory.