cancel
Showing results for 
Search instead for 
Did you mean: 

cannot read application configuration/properties

0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I am getting the same error. It always returns null. Anyone found a solution for this one yet?

Former Member
0 Kudos

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.

0 Kudos

i simply get a null pointer if trying to access these appProps because there are always NULL.

Former Member
0 Kudos

Hi Thomas,

I am having the same problem. I am gettting appProps always null. As this thread was marked answered so I think you might be having the solution for this. Its very urgent for me. Please help me if you can.

Regards,

Murtuza

Former Member
0 Kudos

Have you tried to add a reference to the Configuration Service in your application-j2ee-engine.xml ?

cheers,

Paulo.

Former Member
0 Kudos

Hi,

what error message or exception is thrown ?

That information would help to get an idea on the problem.

Regards, Astrid