Chapter 6. Creating a self-contained Red Hat Process Automation Manager Spring Boot JAR file


You can create a single self-contained Red Hat Process Automation Manager Spring Boot JAR file that contains a complete service, including KIE Server and one or more KJAR files. The Red Hat Process Automation Manager Spring Boot JAR file does not depend on any KJAR files loading at runtime.

If necessary, the Red Hat Process Automation Manager Spring Boot JAR file can contain multiple versions of the same KJAR file, including modules. These KJAR files can have the same artifactID and groupID attribute values, but have different version values.

The included KJAR files are separated from any JAR files in the BOOT-INF/lib directory to avoid class loader collisions. Each KJAR classpath container file is isolated from other KJAR classpath container files and does not rely on the Spring Boot class loader.

Prerequisites

  • You have an existing Red Hat Process Automation Manager Spring Boot project.
  • You have completed development of one or more KJAR files for the project.

Procedure

  1. Build all KJAR files for the project. In the default business application, the KJAR source is contained in the <BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-kjar directory, where BUSINESS-APPLICATION is the name of the business application. Your project might include other KJAR source directories.

    To build the KJAR files, for every KJAR source directory, complete the following steps:

    1. Change to the KJAR source directory.
    2. Enter the following command:

      mvn install
      Copy to Clipboard Toggle word wrap

      This command builds the KJAR file and places it into the local Maven repository. By default, this repository is located in the ~/.m2/repo directory.

  2. In the <BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-service/src/main/resources directory, add the following property to your Spring Boot application application.properties file:

    kieserver.classPathContainer=true
    Copy to Clipboard Toggle word wrap

    When this property is set to true, KIE Server uses the class loader used by the container to load KJAR files and their dependencies.

  3. Complete one of the following actions to ensure that KIE Server loads the necessary KJAR modules:

    • To configure KIE Server to scans and deploy all KJAR modules available in the Spring Boot application, add the following property to the application.properties file:

      kieserver.autoScanDeployments=true
      Copy to Clipboard Toggle word wrap

      When this property is set to true, KIE Server deploys all KJAR modules available in the application, whether they are declared programmatically or through the Maven plug-in.

      This option is the simplest method to include all KJAR modules. However, it has two drawbacks:

      • The application sets all container IDs and aliases automatically, based on the group, artifact, and version (GAV) of every KJAR module. You cannot set a custom container ID or alias for a KJAR module.
      • At startup time, the application scans the JAR file and the class path for KJAR modules. Therefore, the duration of startup might be increased.

      To avoid these drawbacks, you can configure every KJAR module individually using the application.properties file or using Java source code, as described in one of the following options.

    • To configure every KJAR module individually using the application.properties file, for each of the KJAR modules that you want to include in the service, add the following properties to the application.properties file:

      kieserver.deployments[<n>].containerId=<container>
      kieserver.deployments[<n>].alias=<alias>
      kieserver.deployments[<n>].artifactId=<artifact>
      kieserver.deployments[<n>].groupId=<group>
      kieserver.deployments[<n>].version=<version>
      Copy to Clipboard Toggle word wrap

      Replace the following values:

      • <n>: A sequential number: 0 for the first KJAR module, 1 for the second module, and so on
      • <container>: The container ID for the KJAR module
      • <alias>: The alias for the KJAR module
      • <artifact>: The artifact ID for the KJAR module
      • <group>: The group ID for the KJAR module
      • <version>: The version ID for the KJAR module

      The following example configures two versions of the Evaluation KJAR module:

      kieserver.deployments[0].alias=evaluation_v1
      kieserver.deployments[0].containerId=evaluation_v1
      kieserver.deployments[0].artifactId=Evaluation
      kieserver.deployments[0].groupId=com.myspace
      kieserver.deployments[0].version=1.0.0-SNAPSHOT
      
      kieserver.deployments[1].alias=evaluation_v2
      kieserver.deployments[1].containerId=evaluation_v2
      kieserver.deployments[1].artifactId=Evaluation
      kieserver.deployments[1].groupId=com.myspace
      kieserver.deployments[1].version=2.0.0-SNAPSHOT
      Copy to Clipboard Toggle word wrap
    • To configure every KJAR module individually using Java source code, create a class in your business application service, similar to the following example:

      @Configuration
      public class KieContainerDeployer {
      
          @Bean
          public KieContainerResource evaluation_v1() {
              KieContainerResource container = new KieContainerResource("evaluation_v1", new ReleaseId("com.myspace", "Evaluation", "1.0.0-SNAPSHOT"), STARTED);
              container.setConfigItems(Arrays.asList(new KieServerConfigItem(KieServerConstants.PCFG_RUNTIME_STRATEGY, "PER_PROCESS_INSTANCE", "String")));
              return container;
          }
      
          @Bean
          public KieContainerResource evaluation_v2() {
              KieContainerResource container = new KieContainerResource("evaluation_v2", new ReleaseId("com.myspace", "Evaluation", "2.0.0-SNAPSHOT"), STARTED);
              container.setConfigItems(Arrays.asList(new KieServerConfigItem(KieServerConstants.PCFG_RUNTIME_STRATEGY, "PER_PROCESS_INSTANCE", "String")));
              return container;
          }
      }
      Copy to Clipboard Toggle word wrap

      For every KJAR module that you want to include, create a KieContainerResource bean in this class. The name of the bean is the container name, the first parameter of KieContainerResource() is the alias name, and the parameters of ReleaseId() are the group ID, artifact ID, and version ID of the KJAR module.

  4. In the <BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-service directory, add the following Maven plug-in in the Spring Boot service/pom.xml file where <GROUP_ID>, <ARTIFACT_ID>, and <VERSION> are the group, artifact, and version (GAV) of a KJAR artifact that your project uses. You can find these values in the pom.xml file that is located in the KJAR source directory.

    Note

    You can add more than one version of an artifact.

      <build>
        <plugins>
          <plugin>
            <groupId>org.kie</groupId>
            <artifactId>kie-maven-plugin</artifactId>
            <version>${version.org.kie}</version>
            <executions>
              <execution>
                <id>copy</id>
                <phase>prepare-package</phase>
                <goals>
                  <goal>package-dependencies-kjar</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId><GROUP_ID></groupId>
                  <artifactId><ARTIFACT_ID></artifactId>
                  <version><VERSION></version>
                </artifactItem>
              </artifactItems>
            </configuration>
          </plugin>
        <plugins>
      <build>
    Copy to Clipboard Toggle word wrap

    The artifacts required to run the KJAR will be resolved at build time.

    The following example adds two version of the Evaluation artifact:

      <build>
        <plugins>
          <plugin>
            <groupId>org.kie</groupId>
            <artifactId>kie-maven-plugin</artifactId>
            <version>${version.org.kie}</version>
            <executions>
              <execution>
                <id>copy</id>
                <phase>prepare-package</phase>
                <goals>
                  <goal>package-dependencies-kjar</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.myspace</groupId>
                  <artifactId>Evaluation</artifactId>
                  <version>1.0.0-SNAPSHOT</version>
                </artifactItem>
                <artifactItem>
                  <groupId>com.myspace</groupId>
                  <artifactId>Evaluation</artifactId>
                  <version>2.0.0-SNAPSHOT</version>
                </artifactItem>
              </artifactItems>
            </configuration>
          </plugin>
        <plugins>
      <build>
    Copy to Clipboard Toggle word wrap
  5. To build the self-contained Spring Boot image, enter the following command in the <BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-service directory:

    mvn install
    Copy to Clipboard Toggle word wrap
  6. Optional: to run the self-contained Spring Boot image, locate the JAR file in the target subdirectory and enter the following command:

    java -jar <FILENAME>.jar
    Copy to Clipboard Toggle word wrap

    In this command, replace <FILENAME> with the name of the JAR file.

Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat