Page 1 of 1

Loading properties files inside Operations classes

Posted: Fri Jul 17, 2009 3:29 pm
by sijomon
Hi,

I am attempting to load a properties file from inside an Operation class.

My operation is packaged inside a jar file 'acm.jar', the Operation I have loads the properties file as follows:

Code: Select all

Properties properties = new Properties();		properties.load(ClassLoader.getSystemResourceAsStream("CaseLinkOperation.properties"));	
LCR_TOOL_USERNAME = (String)properties.get(LCR_TOOL_USERNAME_KEY);
LCR_TOOL_PASSWORD = (String)properties.get(LCR_TOOL_PASSWORD_KEY);
I have tried deplying the properties file in two ways:

1. In the root of the acm.jar file

2. Inside the ACM framework folder, and then explicity adding the properties file to the classpath of the framework inside the 'Document Type Associations->Classpath' area.

Neither of these work, I just get a null pointer when loading the file.

Any ideas?

Simon.

Re: Loading properties files inside Operations classes

Posted: Fri Jul 17, 2009 3:54 pm
by sorin_ristache
Hello,
sijomon wrote:

Code: Select all

Properties properties = new Properties();		properties.load(ClassLoader.getSystemResourceAsStream("CaseLinkOperation.properties"));
Your jar file is not loaded in Author by the system class loader. Use getClass().getClassLoader().getResourceAsStream("CaseLinkOperation.properties") instead of the system class loader.
sijomon wrote:2. Inside the ACM framework folder, and then explicity adding the properties file to the classpath of the framework inside the 'Document Type Associations->Classpath' area.
This option works too but you have to add to the framework classpath the folder that contains the file CaseLinkOperation.properties, not the file CaseLinkOperation.properties.


Regards,
Sorin

Re: Loading properties files inside Operations classes

Posted: Fri Jul 17, 2009 5:32 pm
by sijomon
many thanks.