on 06-30-2005 3:16 PM
Hi there,
i am trying to supply configuration to my J2EE application at deploy time.
i have found this description how to do it:
-
Include your properties in your EAR. The property file has to be a standard Java-Propertyfile named <i>sap.application.global.properties</i>. It needs to be placed in the META-INF subfolder of your enterprise archive (alongside application.xml). The SAP NetWeaver Developer Studio allows to add this property to any J2EE Enterprise Application Project.
Coding:
The properties can be obtained from the ApplicationConfigHandlerFactory :
//get a handler:
Context ctx = new InitialContext();
ApplicationConfigHandlerFactory appCfgHdl =
(ApplicationConfigHandlerFactory)ctx.lookup("ApplicationConfiguration");
java.util.Properties appProps = appCfgHdl.getApplicationProperties();
if (appProps==null) {
//some reaction if no application properties are available.
} else {
//extract properties
}
-
the problem is it does not work
i have done all the things (i swear ) but the field
<i>appProps</i> is always null
this is the content of my property file
-
#some comment
Simulator.ExecutionMillis=2000
#some comment
Simulator.ErrorProbability=0.1
-
Message was edited by: Thomas Marz
I am getting the same error. It always returns null. Anyone found a solution for this one yet?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have just implemented reading from the application configuration.
I've followed the following steps:
1) Right click on the EAR project
2) New -> "META-INF/sap.application.global.properties"
3) added the following property to the file:
mdm.servername=test
4) build + deploy the application
5) checked if the property was visible in the Visual Admin
Server -> services -> configuration adapter
Runtime -> Display configuration
Configurations -> apps -> browse to your application -> appcfg -> Propertysheet application.global.properties
Found that the property was there...
Now reading it.
I've put the following in my session bean ejbCreate, just to test (exception handling should be more specific etc)
try{
Context ctx = new InitialContext();
ApplicationConfigHandlerFactory cfgHandler = (ApplicationConfigHandlerFactory)ctx.lookup("ApplicationConfiguration");
Properties appProps = cfgHandler.getApplicationProperties();
TRACE.debugT("MDM Server: " + appProps.getProperty("mdm.servername"));
} catch (Exception e){
System.err.println(e.getMessage());
}
Build + deploy, and it works. Hope it helps.
i simply get a null pointer if trying to access these appProps because there are always NULL.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
what error message or exception is thrown ?
That information would help to get an idea on the problem.
Regards, Astrid
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.