getContext returns null

Hi,

I’m trying to read a properties file and in order to do so I need the path of my application:

Properties properties = new Properties();
		try {
			properties.load(new FileInputStream("%somedir%/folder.properties"));
		} catch (Exception e) {
			e.printStackTrace();
		} 
        root = properties.getProperty("folder");

The code above works fine when the %somedir% part is hardcoded.

However, the path should be retrieved dynamically using the following code:

getApplication().getContext().getBaseDirectory().getPath();

The problem is… whereas getApplication() works fine, the getContext() method returns null.

Any ideas what could be the problem?

Regards,
Roland

Hi,

Nothing obvious springs to mind right away…

Could you explain a little bit more about in which stage you’re doing this? Actually a stacktrace could help. And is this regular servlet / Liferay / GAE / …?

Best Regards,
Marc