How to load properties file in JBOSS 6 from other place

1.7k views Asked by At

I want to change location of all properties file but I do not know where to change in JBOSS 6 for new path, I am asking it because I am new in JBOSS.

it uses some default path, for example for "com/test/configuration/main" path is modules/com/test/configuration/main

but I want to load all property from say c:\prop_files\

for it i have tried to modified module.xml

<module xmlns="urn:jboss:module:1.1" name="com.test.configuration">
<resources>
    <resource-root path="c:\props_files\"/>
</resources>
</module>

but it is giving me exception

org.jboss.modules.xml.XmlPullParserException: Failed to add resource root 'C:\props_files' at path 'C:\props_files'

please suggest.

1

There are 1 answers

0
Elvis Rocha On

Firstly, you need to add the path in your configuration file ( standalone.xml/domain.xml).
For example in standalone.xml (it goes after </extensions> and before <management> tag):

<paths>
    <path name="my.home.dir" path="C:\Users\elvis\Downloads"/>
</paths>

You can do that via CLI as well:

./bin/jboss-cli.sh --connect --controller=localhost:9999
/path=my.home.dir:add(path=C:\\Users\\elvis\\Downloads)

Then you reference the path in your application, for example:

String path = System.getProperty("my.home.dir") + propertiesFileName;
Properties props = new Properties();
URL url = new URL(path);
props.load(url.openStream());