Kia ora,
I need to deploy the ORS Java source code to a .jar
file alongside my larger project code. In doing so, I need to specify the ORS config file in use. To date (i.e. in IntelliJ), I have done so by specifying an environment variable:
ORS_CONFIG=custom-ors-config.json
In which I radically increase the search limits for isochrones, etc. Now that I am deploying to a .jar
, I need to specify the environment variable from the terminal. My current method is to append the following to my java initialisation call:
-DORS_CONFIG=custom-ors-config.json
However, the .jar
cannot find the config file (unmoved since compilation), despite the config file (and the default config files) being present in the jar, and I get the following exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.heigit.ors.api.requests.isochrones.IsochronesRequest.validateAgainstConfig(IsochronesRequest.java:559)
at org.heigit.ors.api.requests.isochrones.IsochronesRequest.generateIsochronesFromRequest(IsochronesRequest.java:370)
at gphhemd.definitions.instance.ORSGraph.getIsochronArea(ORSGraph.java:221)
at gphhemd.definitions.instance.Instance.setFacilityCoverage(Instance.java:132)
at gphhemd.definitions.instance.Instance.<init>(Instance.java:67)
at gphhemd.definitions.instance.Instance.readCoordinateInstanceFromFile(Instance.java:555)
at gphhemd.algorithm.EvaluationModel.setup(EvaluationModel.java:153)
at gphhemd.algorithm.ReactiveEMSProblem.setup(ReactiveEMSProblem.java:110)
at ec.Evaluator.setup(Evaluator.java:80)
at ec.simple.SimpleEvaluator.setup(SimpleEvaluator.java:65)
at ec.EvolutionState.setup(EvolutionState.java:399)
at gphhemd.algorithm.EMSEvolutionState.setup(EMSEvolutionState.java:256)
at ec.simple.SimpleEvolutionState.startFresh(SimpleEvolutionState.java:49)
at gphhemd.algorithm.EMSEvolutionState.run(EMSEvolutionState.java:300)
at global.gp.SimpleEvolve.main(SimpleEvolve.java:95)
Caused by: java.lang.IllegalStateException: CAUGHT IO EXCEPTION: No valid configuration file found in 'openrouteservice/src/main/resources'. Did you copy ors-config-sample.json to ors-config.json?
at org.heigit.ors.config.AppConfig.<init>(AppConfig.java:106)
at org.heigit.ors.config.AppConfig.getGlobal(AppConfig.java:132)
at org.heigit.ors.services.isochrones.IsochronesServiceSettings.<clinit>(IsochronesServiceSettings.java:52)
... 15 more
Is there a way I can specify a precise path for a config file instead of merely a name that ORS is expected to find? e.g.
-DORS_CONFIG=/Users/mak/folderA/folderB/custom-ors-config.json
I realise this is a pretty simple question, but my hours of trial and error are proving fruitless.
EDIT: I have hacked this, passing the location of a custom config file to my main class, which I then pass to AppConfig directly as a static parameter. Not ideal, but it works.
Additionally, I need to access the resources folder within the jar, but the LocalizationManager class is making this exceptionally difficult. Any recommendations, there?
Ngā mihi,
Mak