搜索

此内容没有您所选择的语言版本。

Chapter 2. Building and running the employee rostering starter application

download PDF

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 JBoss Developer Studio), to build and run the application.

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

  1. Download the rhdm-7.3.0-add-ons.zip file from the Software Downloads page for Red Hat Decision Manager 7.3.
  2. Unzip the downloaded archive.
  3. Unzip the rhdm-7.3.0-employee-rostering.zip file that is extracted from the add-ons archive.

    The employee-rostering-distribution-7.18.0.Final-redhat-00002 folder is created. This folder is the base folder in subsequent parts of this document.

    Note

    File and folder names might have higher version numbers than specifically noted in this document.

  4. As of version 7.3.0, an additional setting is required in order to build the application from source. You must make the jboss-public-group Maven repository, located at https://repository.jboss.org/nexus/content/groups/public/ , available to your build.

    To make this repository available, modify the sources/pom.xml file in the extracted source code. Add the following content immediately before the <repositories> tag:

    <pluginRepositories>
        <pluginRepository>
          <id>jboss-public-group</id>
          <name>JBoss Public Maven Repository</name>
          <url>https://repository.jboss.org/nexus/content/groups/public/</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>

    Alternatively, you can customize the Maven settings.xml file to make this repository available. For details about using and changing a settings.xml file, see the Maven settings reference.

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

  1. A Java Development Kit must be installed.
  2. Maven must be installed.
  3. The host must have access to the Internet (for downloading Maven packages from external repositories).

Procedure

  1. In a terminal window, change to the sources directory.
  2. Run the following command:

    mvn clean install
  3. Wait for the build process to complete.
  4. Use one of the following methods to run the application:

    1. Run the WildFly server deployed as part of the build process:

      1. In the local/appserver/wildfly-14.0.1-final/standalone/deployments subdirectory, create the optashift-employee-rostering-webapp-<version>.war.dodeploy file. The <version> must be the same as in the existing optashift-employee-rostering-webapp-<version>.war symlink in the same directory.
      2. In the local/appserver/wildfly-14.0.1-final/bin subdirectory, run the ./standalone.sh command.
    2. Deploy the optashift-employee-rostering-webapp/target/optaweb-employee-rostering-*.war file into an existing WildFly or JBoss EAP server and start the application server.
    3. Use the following commands to run a server using Maven:

      mvn -N wildfly:start wildfly:deploy
      mvn gwt:codeserver
      Note

      If 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
  5. Access the application at http://localhost:8080/gwtui/gwtui.html

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

  1. A Java Development Kit must be installed.
  2. Maven must be installed.
  3. The host must have access to the Internet (for downloading Maven packages from external repositories).
  4. You must have a deployed WildFly or Red Hat JBoss EAP application server and a deployed MySQL or PostrgeSQL database server.
  5. You must set up a JDBC data source in the application server for the database server.

Procedure

  1. In a terminal window, change to the sources directory.
  2. Run 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
  3. Wait for the build process to complete.
  4. Deploy the optashift-employee-rostering-webapp/target/optaweb-employee-rostering-7.18.0.Final-redhat-00002.war directory into the application server and start the application server.
  5. Access the application at http://localhost:8080/gwtui/gwtui.html

2.4. Building and running the employee rostering starter application using Eclipse

You can use Eclipse, including Red Hat JBoss Development Studio, to build the employee rostering starter application and run it.

Prerequisites

  1. Eclipse must be installed.
  2. The host must have access to the Internet (for downloading Maven packages from external repositories).
  3. To run the application with the suggested configuration, Google Chrome must be installed. However, you can modify the configuration to use another web browser.

Procedure

  1. Start Eclipse.
  2. From the main menu, select File > Import…​.
  3. Select the Maven > Existing Maven projects wizard.
  4. For the root directory, select the root directory of the application source.
  5. Click Finish.
  6. Optionally, to avoid seeing many errors in Eclipse:

    1. In the root directory of the application source, run the mvn clean install command and wait for the build to finish.
    2. In the Eclipse navigation tree, right-click employee-rostering-shared and select Build Path > Configure Build Path…​.
    3. Click the Source tab, then click Add Folder…​.
    4. Select the employee-rostering-shared/target/generated-sources folder and click OK.
  7. From the main menu, select Run > External Tools > External Tools Configurations…​.
  8. Under Program, create the following launch configurations:

    1. 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

        Note

        You can change the name, location. and arguments to use another browser instead of Chrome.

    2. Kill Code Server:

      • Name: Kill Code Server
      • Location: /usr/sbin/fuser
      • Working Directory: ${workspace_loc:/employee-rostering}
      • Arguments: fuser -k 9876/tcp
  9. From the main menu, select Run > Run Configurations…​.
  10. Under Maven Build, create the following launch configurations:

    1. OptaWeb Employee Rostering Build:

      • Name: OptaWeb Employee Rostering Build
      • Base directory: ${workspace_loc:/employee-rostering}
      • Goals: clean install
      • Parameter: gwt:skipCompilation Value: true
    2. 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
    3. 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
    4. 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
  11. 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
  12. 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.

    Note

    When 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.

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.