0


I am trying to load a properties file in a web application using the following code in Java.

InputStream in = ContextEventListener.class.getResourceAsStream(resourceConstVal);
Properties config = new Properties();
config.load(in);

When this application runs on tomcat server; all the properties specified in the properties file get exported as system variables and are accessible via the following code

System.getProperty("TEMP")

`
However, when the same application ran on Jboss server; the properties had to be explicitly exported by

Set<Object> keySet = config.keySet();
for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
String strVal = (String) iterator.next();
System.setProperty(strVal, config.getProperty(strVal));
}


Using JDK 1.6 , Tomcat 7.0 , Jboss AS 6.1.

Content of Property File
CONTENT_DIR=XXXXXX
RESPONSE_FILE_NM=YYYYYYYY
REQUEST_INT_FILE_NM=ZZZZZZZ

Wondering why behavior varies in different application server.

Allzhere
  • 1,280
  • 1
  • 11
  • 19

1 Answers1

0

That's becouse Jboss puts the .properties file inside jars on the classpath and can not be edited sometime after the deploy. Here is a workaround https://developer.jboss.org/wiki/HowToPutAnExternalFileInTheClasspath

Cassian
  • 3,648
  • 1
  • 29
  • 40