For some reason, I don’t have user.dir and so I get:
com.typesafe.config.ConfigException$UnresolvedSubstitution: reference.conf @ jar:file:/opt/rubrik/src/java/sd/target/sd-0.1.jar!/reference.conf: 3840: Could not resolve substitution to a value: ${user.dir}
at com.typesafe.config.impl.ConfigReference.resolveSubstitutions(ConfigReference.java:111) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ConfigConcatenation.resolveSubstitutions(ConfigConcatenation.java:205) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
I tried everything to try to feed it this directory and all fails:
System.setProperty(“user.dir”, “/tmp”)
private val config =
customConf
.withFallback(ConfigFactory.systemProperties())
.withFallback(ConfigFactory.defaultOverrides())
.withFallback(ConfigFactory.defaultReference())
Other than manually editing reference.conf from the jar, is there a way around this? I am still not sure why I don’t have user.dir. I can see it from Scala repl.sh
That is strange, since user.dir should be a standard jvm system property.
You can define the property in your application.conf: akka.cluster.metrics.native-library-extract-folder but that probably doesn’t help because variable substitutions in reference.conf are performed before application.conf is involved (this has changed in Akka 2.6.0-M7).
Maybe a workaround could be to start the jvm with -Duser.dir=/path/to/your/working/dir.
Another workaround could be to define user.dir = "/path/to/your/working/dir" in a reference.conf file.
Can you share the full stack trace so that I can see where the load starts? Maybe that could happen for ConfigFactory.defaultReference which might not use system properties. I don’t think Akka itself loads config in that way, but let’s look at the stack trace.
com.typesafe.config.ConfigException$UnresolvedSubstitution: reference.conf @ jar:file:/XXX/sd-0.1.jar!/reference.conf: 3840: Could not resolve substitution to a value: ${user.dir}
at com.typesafe.config.impl.ConfigReference.resolveSubstitutions(ConfigReference.java:111) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ConfigConcatenation.resolveSubstitutions(ConfigConcatenation.java:205) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:231) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfig.resolveWith(SimpleConfig.java:78) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfig.resolve(SimpleConfig.java:68) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfig.resolve(SimpleConfig.java:63) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.SimpleConfig.resolve(SimpleConfig.java:41) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ConfigImpl$1.call(ConfigImpl.java:371) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ConfigImpl$1.call(ConfigImpl.java:364) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ConfigImpl$LoaderCache.getOrElseUpdate(ConfigImpl.java:65) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ConfigImpl.computeCachedConfig(ConfigImpl.java:92) ~[sd-0.1.jar:?]
at com.typesafe.config.impl.ConfigImpl.defaultReference(ConfigImpl.java:364) ~[sd-0.1.jar:?]
at com.typesafe.config.ConfigFactory.defaultReference(ConfigFactory.java:367) ~[sd-0.1.jar:?]
at com.typesafe.config.ConfigFactory.defaultReference(ConfigFactory.java:356) ~[sd-0.1.jar:?]
at XXX.integration.spray.SprayServer.(SprayServer.scala:280) ~[sd-0.1.jar:?]
Thanks, as suspected it originates from ConfigFactory.defaultReference.
I created issue https://github.com/akka/akka/issues/27770 for further investigation of improvement.
Thanks, adding a gratuitous reference.conf which contains a user.dir fixes it. Looks like reference.conf cannot reference System variables. How is it working for anyone; I wasn’t trying to do anything special.