-
Language:
English
-
Language:
English
Chapter 2. Building and running the employee rostering starter application
You can build the employee rostering starter application from the source code and run it using a JBoss EAP or WildFly application server.
You can use the command line to build the application, then install it into a stand-alone server.
Alternatively, you can use your IDE, for example, Eclipse (including Red Hat CodeReady Studio), to build and run the application.
You can also deploy and run the pre-built WAR file that is supplied with the source code.
For information about using the application, see Deploying and using the employee roster starter application for Red Hat Business Optimizer on Red Hat OpenShift Container Platform.
2.1. Preparing deployment files
You must download and prepare the deployment files before building and deploying the application.
Procedure
-
Download the
rhpam-7.5.1-reference-implementation.zip
file from the Software Downloads page for Red Hat Process Automation Manager 7.5. - Unzip the downloaded archive.
Unzip the
rhpam-7.5-employee-rostering.zip
file that is extracted from the reference implementation archive.The
employee-rostering-distribution-7.26.0.Final-redhat-00005
folder is created. This folder is the base folder in subsequent parts of this document.NoteFile and folder names might have higher version numbers than specifically noted in this document.
2.2. Building and running the employee rostering starter application from the command line
You can use the command line to build the employee rostering starter application and run it.
If you use this procedure, the data is stored in memory and is lost when the server is stopped. To build and run the application with a database server for persistent storage, see Section 2.3, “Building and running the employee rostering starter application with persistent data storage from the command line”.
Prerequisites
- You prepared the deployment files as described in Section 2.1, “Preparing deployment files”.
- A Java Development Kit is installed.
- Maven is installed.
- The host has access to the Internet. The build process uses the Internet for downloading Maven packages from external repositories.
Procedure
-
In a terminal window, change to the
sources
directory. Enter the following command:
mvn clean install
- Wait for the build process to complete.
Use one of the following methods to run the application:
Run the WildFly server deployed as part of the build process:
-
In the
local/appserver/wildfly-14.0.1-final/standalone/deployments
subdirectory, create theoptaweb-employee-rostering-webapp-<version>.war.dodeploy
file. The<version>
must be the same as in the existingoptaweb-employee-rostering-webapp-<version>.war
symlink in the same directory. -
In the
local/appserver/wildfly-14.0.1-final/bin
subdirectory, enter the./standalone.sh
command.
-
In the
-
Deploy the
optaweb-employee-rostering-webapp/target/optaweb-employee-rostering-*.war
file into an existing WildFly or JBoss EAP server and start the application server. Use the following commands to run a server using Maven:
mvn -N wildfly:start wildfly:deploy mvn gwt:codeserver
NoteIf you use Maven to start the server, the UI uses the gwt codeserver and monitors the gwtui source. In this case, if you change gwtui code, the codeserver picks the changes up automatically; there is no need to rebuild the application for gwtui code changes.
Later, to stop this server, use the command:
mvn -N wildfly:shutdown
- To access the application, enter http://localhost:8080/gwtui/gwtui.html in a web browser.
2.3. Building and running the employee rostering starter application with persistent data storage from the command line
If you use the command line to build the employee rostering starter application and run it, you can provide a database server for persistent data storage.
Prerequisites
- You prepared the deployment files as described in Section 2.1, “Preparing deployment files”.
- A Java Development Kit is installed.
- Maven is installed.
- The host has access to the Internet. The build process uses the Internet for downloading Maven packages from external repositories.
- You have a deployed WildFly or Red Hat JBoss EAP application server and a deployed MySQL or PostrgeSQL database server.
- You have set up a JDBC data source in the application server for the database server.
Procedure
-
In a terminal window, change to the
sources
directory. Enter the following command:
mvn clean install -Dproductized -Dorg.optaweb.employeerostering.persistence.datasource=<dsname> -Dorg.optaweb.employeerostering.persistence.dialect=<dialect>
In the preceding command, replace the following values:
- <dsname> with the name of the data source in the application server.
<dialect> with one of the following strings, depending on the type of database server:
-
For MySQL,
org.hibernate.dialect.MySQL5Dialect
-
For PostgreSQL,
org.hibernate.dialect.PostgreSQLDialect
-
For MySQL,
- Wait for the build process to complete.
-
Deploy the
optaweb-employee-rostering-webapp/target/optaweb-employee-rostering-7.26.0.Final-redhat-00005.war
directory into the application server and start the application server. - To access the application, enter http://localhost:8080/gwtui/gwtui.html in a web browser.
2.4. Building and running the employee rostering starter application using Eclipse
You can use Eclipse, including Red Hat CodeReady Studio, to build the employee rostering starter application and run it.
Prerequisites
- You prepared the deployment files as described in Section 2.1, “Preparing deployment files”.
- Eclipse is installed.
- The host has access to the Internet. The build process uses the Internet for downloading Maven packages from external repositories.
- Google Chrome is installed in order to run the application with the suggested configuration.
You can modify the configuration to use another web browser.
Procedure
- Start Eclipse.
- From the main menu, select File > Import….
- Select the Maven > Existing Maven projects wizard.
- For the root directory, select the root directory of the application source.
- Click Finish.
Optionally, to avoid seeing many errors in Eclipse:
-
In the root directory of the application source, enter the
mvn clean install
command and wait for the build to finish. -
In the Eclipse navigation tree, right-click
employee-rostering-shared
and select Build Path > Configure Build Path…. - Click the Source tab, then click Add Folder….
-
Select the
employee-rostering-shared/target/generated-sources
folder and click OK.
-
In the root directory of the application source, enter the
- From the main menu, select Run > External Tools > External Tools Configurations….
Under Program, create the following launch configurations:
Open OptaWeb Employee Rostering in Chrome:
-
Name:
Open OptaWeb Employee Rostering in Chrome
-
Location:
/usr/bin/google-chrome
-
Working Directory:
${workspace_loc:/employee-rostering}
Arguments:
--incognito http://localhost:8080/gwtui/gwtui.html
NoteYou can change the name, location. and arguments to use another browser instead of Chrome.
-
Name:
Kill Code Server:
-
Name:
Kill Code Server
-
Location:
/usr/sbin/fuser
-
Working Directory:
${workspace_loc:/employee-rostering}
-
Arguments:
fuser -k 9876/tcp
-
Name:
- From the main menu, select Run > Run Configurations….
Under Maven Build, create the following launch configurations:
OptaWeb Employee Rostering Build:
-
Name:
OptaWeb Employee Rostering Build
-
Base directory:
${workspace_loc:/employee-rostering}
-
Goals:
clean install
-
Parameter:
gwt:skipCompilation
Value:true
-
Name:
OptaWeb Employee Rostering Start Code Server:
-
Name:
OptaWeb Employee Rostering Start Code Server
-
Base directory:
${workspace_loc:/employee-rostering}
-
Goals:
gwt:codeserver
-
Parameter:
gwt:skipCompilation
Value:true
-
Name:
OptaWeb Employee Rostering Start Webserver:
-
Name:
OptaWeb Employee Rostering Start Webserver
-
Base directory:
${workspace_loc:/employee-rostering}
-
Goals:
wildfly:start wildfly:deploy
-
Parameter:
gwt:skipCompilation
Value:true
-
Name:
OptaWeb Employee Rostering Stop Webserver:
-
Name:
OptaWeb Employee Rostering Stop Webserver
-
Base directory:
${workspace_loc:/employee-rostering}
-
Goals:
wildfly:shutdown
-
Parameter:
gwt:skipCompilation
Value:true
-
Name:
Under Launch Group, create a launch group named
OptaWeb Employee Rostering Run
. Add the following launches to it:-
Program::Kill Code Server
Launch mode: inherit Post launch action: Wait until terminated -
Maven Build::OptaWeb Employee Rostering Stop Webserver
Launch mode: inherit Post launch action: Wait until terminated -
Maven Build::OptaWeb Employee Rostering Build
Launch mode: inherit Post launch action: Wait until terminated -
Maven Build::OptaWeb Employee Rostering Start Webserver
Launch mode: inherit Post launch action: none -
Maven Build::OptaWeb Employee Rostering Start Code server
Launch mode: inherit Post launch action: Wait for console output (regexp):The code server is ready at
-
Program::Open OptaWeb Employee Rostering in Chrome
Launch mode: inherit Post launch action: none
-
To build, run, and immediately acccess the application, run the
OptaWeb Employee Rostering Run
launch group. You can then change the application and rerun the launch group to test your changes.NoteWhen you use this method to run the application, the UI uses the gwt codeserver and monitors the gwtui source. If you change gwtui code, the codeserver picks the changes up automatically; there is no need to rebuild the application for gwtui code changes.
2.5. Running the supplied pre-built WAR file
To access the Employee Rostering starter application, you can deploy and run the pre-built employee-rostering-webapp-7.26.0.Final-redhat-00005.war
file that is supplied with Red Hat Process Automation Manager.
Prerequisites
- You prepared the deployment files as described in Section 2.1, “Preparing deployment files”.
- A Java Development Kit is installed.
- You have a deployed WildFly or Red Hat JBoss EAP application server.
Procedure
In your WildFly or Red Hat JBoss EAP application server, enable property replacement. For more information about enabling and disabling property replacement in Red Hat JBoss EAP, see Property Replacement in the Red Hat JBoss Enterprise Application Platform 7.2 Configuration Guide.
- Start the application server in standalone mode.
Start the management CLI by entering the following command:
EAP_HOME/bin/jboss-cli.sh --connect
In the management CLI enter the following command:
/subsystem=ee:write-attribute(name="spec-descriptor-property-replacement",value=true)
- Stop the application server.
-
Deploy the
binaries/employee-rostering-webapp-7.26.0.Final-redhat-00005.war
directory into the application server and start the application server. - To access the application, enter http://localhost:8080/gwtui/gwtui.html in a web browser.