|
|
|
|||||
|
Cannot read config file using Java ClassLoader
Hey,
I've packaged the configuration file for my ICE client, nvacconfig, into a JAR file, at the path config/nvacconfig. I can load this config file normally using Ice.InitializationData.properties.load(String file), but I cannot do that from inside my JAR; I need to use a ClassLoader to read the file. Seeing as InitializationData.properties.load() only takes a String argument, I cannot pass the file as an InputStream, which is what I would normally do: Code:
ClassLoader cl = this.getClass().getClassLoader();
InputStream file = cl.getResourceAsStream("config/nvacconfig");
Ice.InitializationData id;
try {
id = new Ice.InitializationData();
id.properties = Ice.Util.createProperties();
id.properties.load(file);
// Does not work
Is there a way to load this configuration file properly to the InitializationData using a ClassLoader? Is there another way to load this configuration file? Thanks, Dan |
|
||||||
|
Hi,
No it's currently not possible to automatically load the configuration file from the Jar file (so you'll have to load the configuration file yourself and setup the properties "manually"). If you would like this feature to be added to Ice, please contact us at info@zeroc.com. Cheers, Benoit. |
|
|||||
|
Hello,
Thanks for the reply. I am a bit lost however as to how to setup the properties from the configuration file manually. I altered my Ice.Communicator.stringToProxy calls by simply hard-coding the appropriate information, such as: Code:
base = NVACMain.getIC().stringToProxy("IceStorm/TopicManager:tcp -p port -h localhost");
I've tried using three different arguments, none of which have worked correctly: Code:
String[] argv = {"Ice.Default.Locator=IceGrid/Locator:default -h localhost -p port",
"IceGrid/Locator:default -h localhost -p port",
"--IceGrid/Locator:default -h localhost -p port"};
try {
ic = Ice.Util.initialize(argv);
} catch (Exception e) {
e.printStackTrace();
}
I am positive the problem lies in the IceGrid Locator, as I was not registering any events from IceStorm without loading the config file, even if I specified the appropriate proxies and topicnames. Is there a way to do what I am trying to do? Can I manually specify the IceGrid Locator information? Is there another way I can go about doing this? Thanks, Dan |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using config file with Java client | Djaunl | Help Center | 2 | 03-15-2007 02:43 PM |
| config file properties | Greenhippo | Help Center | 3 | 01-16-2007 03:07 AM |
| Program implementation / File Transfer Questions (yes, i have read the faq :) )/ Ruby | EmmanuelOga | Help Center | 2 | 08-01-2006 05:58 PM |
| Do 'setProperty' really set value to config file? | kemp | Help Center | 2 | 07-22-2005 05:46 AM |
| set config properties w/o config file | dkey | Help Center | 3 | 05-08-2005 05:27 AM |