Loading properties files inside Operations classes

Having trouble installing Oxygen? Got a bug to report? Post it all here.
sijomon
Posts: 83
Joined: Wed May 20, 2009 1:18 pm

Loading properties files inside Operations classes

Post 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.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Loading properties files inside Operations classes

Post 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
sijomon
Posts: 83
Joined: Wed May 20, 2009 1:18 pm

Re: Loading properties files inside Operations classes

Post by sijomon »

many thanks.
Post Reply