Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-404

maven-exec-plugin JVM arguments aren't getting passed to the VM

    XMLWordPrintable

Details

    • NEW
    • NEW

    Description

      When running mvn exec:java, the arguments from the pom aren't passed to the JVM but as command line arguments to OptaPlannerExamplesApp.

      You can verify this by substituting your own mainClass into the config that prints out the needed debugging info.

      There are two possibilities to fix this:

      A. Switch to mvn exec:exec and set up the configuration like this:

      <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <!-- WARNING: This configuration must be run with "mvn exec:exec" not "mvn exec:java". -->
          <!-- It is impossible to write a configuration that is compatible with both exec:java and exec:exec -->
          <configuration>
              <executable>java</executable>
              <arguments>
              <argument>-Xms256m</argument>
              <!-- Most examples run (potentially slower) with max heap of 128 MB (so -Xmx128m), but 1 example's dataset requires 1.5 GB -->
              <argument>-Xmx1536m</argument>
              <argument>-server</argument>
              <argument>-classpath</argument>
              <classpath />
              <argument>org.optaplanner.examples.app.OptaPlannerExamplesApp</argument>
              </arguments>
          </configuration>
      </plugin>
      

      B. Remove the JVM options from the pom

      Proof code:

      package org.optaplanner.examples.app;
      
      import java.lang.management.ManagementFactory;
      import java.lang.management.RuntimeMXBean;
      import java.util.Arrays;
      import java.util.List;
      
      public class OptaPlannerExamplesAppTest {
      
          public static void main(String[] args) {
              System.out.println("Command-line arguments: " + Arrays.toString(args));
              RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
              List<String> arguments = runtimeMxBean.getInputArguments();
              System.out.println("JVM arguments: " + arguments);
              System.exit(0);
          }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            oskopek Ondrej Skopek (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: