Error: Could not find or load main class ${argLine}

Hi,

I am trying to build a metasfresh distributable from command line following procedures described in http://docs.metasfresh.org/developers_collection/en/getting_started_mvn_cmdline_en.html document.
While running build of metasfresh/de.metas.reactor I've got an error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project de.metas.migration.base: There are test failures.
[ERROR]
[ERROR] Please refer to /home/xxxxx/tools/metasfresh/repos/metasfresh/de.metas.migration/de.metas.migration.base/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/xxxxx/tools/metasfresh/repos/metasfresh/de.metas.migration/de.metas.migration.base && /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/bin/java '${argLine}' -Xms256m -Xmx2048m -jar /home/xxxxx/tools/metasfresh/repos/metasfresh/de.metas.migration/de.metas.migration.base/target/surefire/surefirebooter2021524300946757877.jar /home/xxxxx/tools/metasfresh/repos/metasfresh/de.metas.migration/de.metas.migration.base/target/surefire 2017-11-21T11-14-54_374-jvmRun1 surefire1595626035213636341tmp surefire_04554626986173645225tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/xxxxx/tools/metasfresh/repos/metasfresh/de.metas.migration/de.metas.migration.base && /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/bin/java '${argLine}' -Xms256m -Xmx2048m -jar /home/xxxxx/tools/metasfresh/repos/metasfresh/de.metas.migration/de.metas.migration.base/target/surefire/surefirebooter2021524300946757877.jar /home/xxxxx/tools/metasfresh/repos/metasfresh/de.metas.migration/de.metas.migration.base/target/surefire 2017-11-21T11-14-54_374-jvmRun1 surefire1595626035213636341tmp surefire_04554626986173645225tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:679)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:279)

In a dumpstream file in /home/xxxxx/tools/metasfresh/repos/metasfresh/de.metas.migration/de.metas.migration.base/target/surefire-reports directory there is a further explanation of the above error:

Error: Could not find or load main class ${argLine}

I see there is mentioning of JaCoCo plug-in in metasfresh-parent/pom.xml file.

Should this plug-in be mentioned in mvn install command or some other solution applied?

Maven environment is as follows:

Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T02:58:13-05:00)
Maven home: /home/xxxxx/.sdkman/candidates/maven/current
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.92-18.36-default", arch: "amd64", family: "unix"

Please, let me know if addition info is needed.

Thank you,
George

Hi,

Adding -DargLine= to mvn install command helped to overcome the error and to build metasfresh/de.metas.reactor directory.

Building other directories also requires option -DargLine=:

metasfresh/de.metas.esb
metasfresh-webui
metasfresh-procurement-webui

Is it the right way to do so? Should argLine be set to something else?

Thank you,
George

1 Like

Hi @gp1864
thank you very much for looking into the problem and finding the wokraround.

Is it the right way to do so?

Currently your are actually the leading expert in this matter :slight_smile: (no irony!).
If you have the time, I would be very happy if you could create an issue on github.

The problem might be due to a wrong configuration of the surefire plugin on the parent pom.xml that sits in metasfresh-parent.
Strangely, the automated builds done by our jenkins don’t suffer from the problem…just our local cmd lines…

Best regards,
Tobias

Issue #3073 has been created.

George

Thx. FYI, I hope i was able to solve it here

While executing, when JVM does not find a .class file with the specified name then a run time error occurs saying “Could not found or load main class”. The reason why this happens is mostly due to:

  • Wrong Class Name
  • Invalid Classpath

Main class could not be found when there is typo or wrong syntax in the fully qualified java class name or it does not exist in the provided classpath. You must ensure that you add the location of your .class file to your classpath. So, if its in the current folder, add . to your classpath. Note that the Windows classpath separator is a semi-colon ; . If you want to execute the main() method in MainClass, you must use the full class name, including package name, in the java command.