Java source to Jar: .json config file

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:


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:


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(
	at org.heigit.ors.api.requests.isochrones.IsochronesRequest.generateIsochronesFromRequest(
	at gphhemd.definitions.instance.ORSGraph.getIsochronArea(
	at gphhemd.definitions.instance.Instance.setFacilityCoverage(
	at gphhemd.definitions.instance.Instance.<init>(
	at gphhemd.definitions.instance.Instance.readCoordinateInstanceFromFile(
	at gphhemd.algorithm.EvaluationModel.setup(
	at gphhemd.algorithm.ReactiveEMSProblem.setup(
	at ec.Evaluator.setup(
	at ec.simple.SimpleEvaluator.setup(
	at ec.EvolutionState.setup(
	at gphhemd.algorithm.EMSEvolutionState.setup(
	at ec.simple.SimpleEvolutionState.startFresh(
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>(
	at org.heigit.ors.config.AppConfig.getGlobal(
	... 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.


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,

Hi @makalakalak,

we are currently working on making ors deployable as a .jar file by making proper use of the spring-boot framework.
You can track the progress here.

Best regards