OpenMole crash/The request allStates failed



currently I’m trying to get my java application running with openmole. My JAR file includes all source code, but not my sqlite input database and additional input, such as a OSM graph.
I uploaded needed files in the folder, where the jar and oms files are stored and kept the relative folder path the same.
The common java command to execute the application is
java -Xms2048M -Xmx2048M -XX:+UseParallelGC -jar application.jar -scenario 1 -iteration 1 - -inputDB C:\userABC\input.sqlite

My oms script looks like this

val i = Val[Array[String]]
val o = Val[String]

//Defines the task to perform the hello function
val javaTask = ScalaTask("val o = package.start.Main.main(i)") set (
  libraries += workDirectory / "application.jar",
  inputs += i,
  outputs += o,
  i := Array("-scenario 1 ", "-iteration 1 ", ""-inputDB C:\userABC\input.sqlite""")


When I run the script, openmole goes in the running state but crashes after 10 seconds. The cmd console is closed automatically and the web interface shows anerror message "The request allStates failed. The request saveFile failed."
Any idea what could be wrong?

Thanks for your help.



several points:

  • first you can find the error by clicking on the red failed status in the execution panel,
  • you need to provide your data files to the task,
  • the return of the main function in java is int so you cannot get a string from there.

Could you try to craft another function than the main one which return the string you want:

val o = Val[String]
val osm = Val[File]
val sqliteDB = Val[File]

//Defines the task to perform the hello function
val javaTask = ScalaTask("""
  val o = package.start.Main.myFunction(1, 1, sqliteDB)""") set (
  libraries += workDirectory / "application.jar",
  inputs += (osm, sqliteDB),
  outputs += o,
  osm := workDirectory / "file.osm",
  sqliteDB := workDirectory / "db.sqlite"


thanks for your help.
Just another question. My main function needs a (String[] args) as input. Your suggestion would have several parameters as input. That’s why the execution currently fails

(org.openmole.core.console.ScalaREPL$CompilationError: (line 14) too many arguments for method main: (x$1: Array[String])). 

How can I start the jar file with just a single string array which includes all arguments as key value combination (-key value). My basic idea was to construct a String array as shown in my previous post. Doing this, it would be necessary to input a string with the file location of “workingDirectry / db.sqlite” and not a file object.

Any idea how to achieve this?

Could it be a problem, that my jar file creates an output database in a relative folder to the jar file, such as /output/simulation/results_TimeDate_ScenarioID_Iteration.sqlite (e.g. results_20170903_201921_1_1.sqlite)? The output datebase is not created by openmole itself.

Do I have to take this creation into account within the oms file?

(Jonathan Passerat Palmbach) #4

Hello @Streetworker

I think what @reuillon suggest is to bypass the limits of the main function by creating another function in your jar that would be called by main, ingest the Array[String] and produce the command line you need for your application.

I’m not too sure to understand your problem fully but if you want to go from this Array[String] to some File variable, shouldn’t your code in the jar create some new File(...) from what’s in the Array[String]?

As for your other question, no you don’t have to take the resulting DB creation into account.
Just point the outputFile field of your task to the location where your jar produces this DB and you can retrieve it in an OpenMOLE Val[File] variable to move it elsewhere/use it further down in your script.

(Jonathan Passerat Palmbach) #5

5 posts were split to a new topic: How to return a List[File] instead of of a single variable o = Val[]

(Jonathan Passerat Palmbach) #10

2 posts were split to a new topic: Exploration parameters when using multi-threading in LocalEnvironment