on 01-12-2006 6:17 PM
Our application reads configuration information from two external Java properties files. One of these files must be located in the classpath. Since the application was not developed in NWDS (we use Eclipse 3.x), we use the deploy tool to deploy the EAR (containing WAR and EJB jar). We tried using the project classpath in the project options of the deploy tool to specify the local directory where to find the Java properties file. However, this did not work as our app was unable to find the file. We had to put the directory on the JVM's system classpath, which is not ideal.
How exactly do the entries specified for project classpath get inserted into the class loader heirarchy of NetWeaver AS? Or do they? I have read "Extended Java Class Loading of SAP NetWeaver" but did not see any mention of the project classpath set using the deploy tool.
The problem with putting property files in WEB-INF/classes is that if you have environment sensitive properties, you have to re-build the WAR for each environment. We have several properties that define host names and ports for various services. These change depending on the environment (i.e. dev, uat, prod).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I disagree with that approach. Why build multiple WAR files? I want to build just one WAR file for all environments and then a local configuration file provides environment specific information. The configuration file contains sensitive information that only the system administrator should know and not the application assembler.
Hi,
I don't understand the problem very well, but I have used Property files often and did not experience difficulties.
I ususally place the properties files in the WEB-INF/classes directory, this way they get loaded automatically.
And for retrieving properties settings in my application I use this code:
package whatever.utils;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;
import com.sapmarkets.isa.core.logging.IsaLocation;
public class WhateverProperties {
private static Properties properties;
static {
loadProperties();
}
private static void loadProperties() {
final String RESOURCE = "/propertiesfilename.properties";
try {
properties = new Properties();
InputStream is = WhateverProperties.class.getResourceAsStream(RESOURCE);
properties.load(is);
} catch(Exception ioexc) {
...
...
}
}
public static String getProperty(String prop) {
return properties.getProperty(prop);
}
public static Enumeration getPropertyNames() {
return properties.propertyNames();
}
}
Good luck!
Roelof
Message was edited by: R. Knibbe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.