I have a properties file in my spring boot application that uses environment variables
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=${env:keyStorePassword}
org.apache.ws.security.crypto.merlin.keystore.alias=${env:keyAlias}
org.apache.ws.security.crypto.merlin.keystore.file=${env:keyStoreFilePath}
However, it says it cannot find the file, while at the same time providing the path for the file. So it is pulling the value from the environment file correctly. I also copied and put the literal values instead of environment variables into the properties file, and it worked perfectly. Why is it that when I pull from the environment that it says it can't find the file?
This is the error log
17:06:12.537 [http-nio-8080-exec-1] DEBUG org.apache.ws.security.util.Loader - Trying to find [<file>] using org.springframework.boot.loader.LaunchedURLClassLoader@38af3868 class loader.
17:06:12.542 [http-nio-8080-exec-1] DEBUG org.apache.ws.security.util.Loader - Trying to find [<file>] using org.springframework.boot.loader.LaunchedURLClassLoader@38af3868 class loader.
17:06:12.559 [http-nio-8080-exec-1] DEBUG org.apache.ws.security.util.Loader - Trying to find [<file>] using ClassLoader.getSystemResource().
17:06:12.568 [http-nio-8080-exec-1] DEBUG org.apache.ws.security.components.crypto.Merlin - <file> (No such file or directory)
java.io.FileNotFoundException: ${env:keyStoreFilePath} (No such file or directory)
The tag is the exact same file path as in the environment variable.
Thanks for any help you can provide.
I solved this error, for reasons I still do not fully understand, the environment variable was being stored in some different format. So instead, I injected the variables into the properties file by using some good old java.
try {
PropertiesConfiguration props = new PropertiesConfiguration(System.getenv("SIGNATURE_PROPS_FILE"));
props.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", System.getenv("KEY_STORE_PASSWORD"));
props.setProperty("org.apache.ws.security.crypto.merlin.keystore.alias", System.getenv("KEY_ALIAS"));
props.setProperty("org.apache.ws.security.crypto.merlin.keystore.file", System.getenv("KEY_STORE_FILE"));
props.save();
logger.debug("** signature.properties updated Successfully!! **");
} catch (ConfigurationException e) {
logger.error(e.getMessage());
}