JBoss property in .properties file does not work
-
25-06-2021 - |
Domanda
In my Java .properties
file I have this line:
KEYSTORE_PATH=${jboss.server.data.dir}/myapp/keys/keystore.jks
In all other files e.g. log4j.properties
jboss.server.data.dir
is changed to C:\\jboss\server\default\log
and it's ok.
But here I get this exception:
java.io.FileNotFoundException: ${jboss.server.data.dir}\myapp\keys\keystore.jks (The system cannot find the path specified)
It looks like JBoss does not change its property name to the dir
name.
Soluzione
If you are loading your properties file via the java.util.Properties
type, there is no special handling of value placeholders. There are several third party libraries that provide such capabilities. Spring being one of them.
Another option is to use the -C command line option when starting JBoss 4.x to specify a custom properties file. When loaded, JBoss will resolve the value placeholders correctly. The loaded, fully resolved properties can then be accessed via the various System.getProperties
and System.getProperty
methods.