seen during startup ("Can't promise read/write on cache dir")

  • Updated


I see Can't promise read/write on cache dir, error when starting up, for example:

[Contrast] Mon Jun 08 15:01:20 CDT 2020 Starting Contrast (build Pat. 8,458,789 B2
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(
Caused by: com.contrastsecurity.agent.h: Unable to create references to working directories
at com.contrastsecurity.agent.config.o.a(
at com.contrastsecurity.agent.config.e.a(
at com.contrastsecurity.agent.config.d$4.b(
at com.contrastsecurity.agent.config.d$4.a(
at com.contrastsecurity.agent.o.a(
at com.contrastsecurity.agent.config.d.a(
at com.contrastsecurity.agent.config.e.a(
at com.contrastsecurity.agent.config.g.b(
at com.contrastsecurity.agent.config.g.a(
at com.contrastsecurity.agent.config.g.a(
at com.contrastsecurity.agent.h.d.a(
at com.contrastsecurity.agent.h.d.a(
at com.contrastsecurity.agent.j.a.b(
at com.contrastsecurity.agent.core.ContrastAgent.startup(
at com.contrastsecurity.agent.core.ContrastAgent.setup(
at com.contrastsecurity.agent.ContrastLoaderAgent.premain(
... 6 more
Caused by: Can't promise read/write on cache dir
at com.contrastsecurity.agent.config.w.c(
at com.contrastsecurity.agent.config.w.a(
at com.contrastsecurity.agent.config.o.a(
... 21 more


This means that the agent doesn't have read/write access to the cache directory.


By default, the Contrast working directory is located at ${HOME}/.contrast of the user account the application runs under, and requires permissions 755. The cache is a sub-directory of the working directory. If the location of this directory has been modified (for example with the -Dcontrast.agent.contrast_working_dir property), or if the application (and therefore the agent) is running with permissions that prevent the agent the necessary access to its cache, you must modify the permissions to allow this access.

To address the issue, you can ensure that the default Contrast working directory and it's sub-directories have the necessary 755 permissions.

Alternatively, you can add -Dcontrast.agent.contrast_working_dir to point to a directory that the user has ensured access to. This value will override the default Contrast working directory and creates the directory if it does not exist.

More information on configuring the contrast directory can be found in our Java docs.

Was this article helpful?

1 out of 1 found this helpful

Have more questions? Submit a request