Results 1 to 3 of 3

Thread: Using config file with Java client

  1. #1
    Djaunl is offline Registered User
    Name: Dan Gresh
    Organization: LLE
    Project: EP control systems
    Join Date
    Mar 2007
    Posts
    15

    Using config file with Java client

    Hi,

    I'm practically brand new to ICE, and I'm trying to run a simple Java client; the server is already written in C++. I've been reading through the documentation extensively to get myself up to speed, but I'm having some difficulty.

    I have a small .ice file which I've compiled with slice2java into a slice definition. However, I cannot get my client to run properly, and I believe it is caused by two problems.

    First, I was told by the person who wrote the C++ server to include a configuration file with:

    Code:
    Ice.Trace.Network = 0
    Ice.Default.Locator = IceGrid/Locator:default -h localhost -p 11010
    LOTFVigra.Proxy = LOTFVigra@LOTFVigra
    I understand what the first two lines are for, but not really the third. I've asked the person who wrote the server what that is for. Either way, I do not understand how to use this configuration file (named "config") in my client. I searched the web and found that I would need a --Ice.Config argument passed to the Ice runtime, correct? I'm not sure how I would do this. Would I do it when I compile the client code in Java? When I run it? Or is there another way?

    Second, I am uncertain of how to determine the object identity to use in the Ice.Communicator.stringtoProxy method. I'm following the HelloWorld example in the documentation by creating a Ice.Communicator, initializing it, creating an Object proxy, and performing a checked cast:

    Code:
    Ice.Communicator ic = null;
    try {
          ic = Ice.Util.initialize(args);
          Ice.ObjectPrx base = ic.stringToProxy("IMAQ:default -h localhost -p 11010";
          LOTFVigra.ImageAcquisitionPrx imAq = LOTFVigra.ImageAcquisitionPrxHelper.checkedCast(base);
    However, when I attempt to run the client, I get the error:

    Ice.ObjectNotExistException
    id.name = "IMAQ"
    id.category = ""
    facet = ""
    operation = "ice_isA"
    at IceInternal.Outgoing.invoke(Outgoing.java:148)
    at Ice._ObjectDelM.ice_isA(_ObjectDelM.java:31)
    at Ice.ObjectPrxHelkperBase.ice_isA(ObjectPrxHelperBa se.java:86)
    at Ice.ObjectPrxHelkperBase.ice_isA(ObjectPrxHelperBa se.java:61)
    at LOTFVigra.ImageAcquisitionPrxHelper.checkedCast(Im ageAcquisitionPrxHelper.java:70)
    at Client.main(Client.java:8)

    If I need to provide more information or if I am missing something else, please let me know.

    Thanks,
    Dan

  2. #2
    mes's Avatar
    mes
    mes is online now ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Hi Dan,

    There are many ways to use a configuration file. The most common way is using the --Ice.Config command line option, such as

    $ java MyProgram --Ice.Config=config

    You can also load a configuration file programmatically into an Ice.Properties object and then supply that object when calling Ice.Util.initialize:

    Code:
    Ice.InitializationData id = new Ice.InitializationData();
    id.properties = Ice.Util.createProperties();
    id.properties.load("config");
    Ice.Communicator ic = Ice.Util.initialize(id);
    Chapter 30 of the Ice manual describes the use of properties and configuration files in detail.

    Regarding the LOTFVigra.Proxy property, I believe your client should be passing the value of this property to stringToProxy:

    Code:
    String proxy = communicator.getProperties().getProperty("LOTFVigra.Proxy");
    Ice.ObjectPrx base = communicator.stringToProxy(proxy);
    In Ice 3.2, there's an even easier way to convert a stringified proxy contained in a property into a proxy object:

    Code:
    Ice.ObjectPrx base = communicator.propertyToProxy("LOTFVigra.Proxy");
    You are getting Ice.ObjectNotExistException because you are attempting to use a proxy that contains your application-specific identity (IMAQ) and the endpoint of the locator. No such object exists in the locator service, so the Ice run time raises that exception. If this is the identity of a well-known object, you can use stringToProxy("IMAQ"). See chapters 32 and 38 for more information on using the locator service.

    Hope that helps,
    - Mark

  3. #3
    Djaunl is offline Registered User
    Name: Dan Gresh
    Organization: LLE
    Project: EP control systems
    Join Date
    Mar 2007
    Posts
    15
    Hi Mark,

    Thanks for the help, and I apologize for taking so long to respond; I have been busy with other projects recently.

    The --Ice.Config=config command line argument worked fine for me when I ran my Client.

    Replacing my current method of calling a proxy with:

    Code:
    Ice.ObjectPrx base = communicator.propertyToProxy("LOTFVigra.Proxy");
    allows me to connect to the server. At first it was giving me an error, which I cannot display here because it seemed to have solved itself, about not finding any endpoints for the proxy object. I am not too sure what the error said, as I cannot get to it now; I ran my code again today to see what the error was, but now it is working. Therefore, I believe it was a problem with the server the other day, and something I need to ask the server admin about.

    My problem is solved now, so thank you again for the help.

    Dan

    EDIT: The reason my Client was not running previously is because the server admin had killed the server to modify it.
    Last edited by Djaunl; 03-15-2007 at 03:00 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to use my config file in VS 2005
    By bxhsix in forum Help Center
    Replies: 2
    Last Post: 03-30-2008, 03:46 AM
  2. Cannot read config file using Java ClassLoader
    By Djaunl in forum Help Center
    Replies: 4
    Last Post: 05-18-2007, 03:45 PM
  3. config file properties
    By Greenhippo in forum Help Center
    Replies: 3
    Last Post: 01-16-2007, 03:07 AM
  4. Replies: 2
    Last Post: 07-22-2005, 05:46 AM
  5. set config properties w/o config file
    By dkey in forum Help Center
    Replies: 3
    Last Post: 05-08-2005, 05:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •