Results 1 to 8 of 8

Thread: ICE_CONFIG not honored under Java in 3.3

  1. #1
    joshmoore is offline Registered User
    Name: Josh Moore
    Organization: Glencoe Software, Inc.
    Project: OMERO, http://trac.openmicroscopy.org.uk/omero
    Join Date
    Feb 2007
    Location
    Germany
    Posts
    110

    ICE_CONFIG not honored under Java in 3.3

    I may be misunderstanding under what conditions ICE_CONFIG is used in Java, but the attached tests shows that what I think is a straight-forward usage does not work, while it does so in Python.

  2. #2
    joshmoore is offline Registered User
    Name: Josh Moore
    Organization: Glencoe Software, Inc.
    Project: OMERO, http://trac.openmicroscopy.org.uk/omero
    Join Date
    Feb 2007
    Location
    Germany
    Posts
    110

  3. #3
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    I tried using ICE_CONFIG with Ice 3.3 and java and it worked for me. However I may not be attempting to use it in the same way as you, as I was unable to access your attachment. How did you attach the file? It does not appear to have been done using the regular message attachment feature. Also, what version of Java are you using?

  4. #4
    joshmoore is offline Registered User
    Name: Josh Moore
    Organization: Glencoe Software, Inc.
    Project: OMERO, http://trac.openmicroscopy.org.uk/omero
    Join Date
    Feb 2007
    Location
    Germany
    Posts
    110
    Sorry about the attachment. For whatever reason, they don't seem to be working for me. Instead, here's a script file to run the whole test:
    Code:
    #!/bin/bash
    
    test -e "$CLASSPATH" || {
        echo "$CLASSPATH unfound. Set CLASSPATH to Ice-3.3.0.jar"; exit 1
    }
    
    echo `uname -a`
    echo `java -version`
    echo =========================
    
    rm -rf test
    mkdir test
    cat > test/iceconfigtest.cfg<<EOF
    omero.user=me
    EOF
    
    cat > test/iceconfigtest.java<<EOF
    public class iceconfigtest
    {
    
        public static void main(String[] args)
        {
    
            System.out.println("ENV:" + System.getenv("ICE_CONFIG"));
            Ice.InitializationData id = new Ice.InitializationData();
            id.properties = Ice.Util.createProperties();
            if ( args.length > 0 )
            {
                for ( String arg : args )
                {
                    System.out.println("Loading: " + arg);
                    id.properties.load( arg );
                }
            }
    
            Ice.Communicator ic = Ice.Util.initialize( id );
            try
            {
                String value = ic.getProperties().getProperty("omero.user");
                System.out.println("ICE:" + value);
                assert "me".equals(value);
            }
            finally
            {
                ic.destroy();
            }
    
        }
    }
    EOF
    
    cat > test/iceconfigtest.py<<EOF
    import Ice, os
    
    print "ENV: " + os.environ["ICE_CONFIG"]
    id = Ice.InitializationData()
    ic = Ice.initialize(id)
    
    value = ic.getProperties().getProperty("omero.user")
    print value
    assert value == "me"
    EOF
    
    cd test
    echo Compiling
    javac -cp $CLASSPATH iceconfigtest.java
    echo Passes with value on command line
    env ICE_CONFIG=iceconfigtest.cfg java -ea -cp $CLASSPATH:. iceconfigtest iceconfigtest.cfg
    echo Fails without.
    env ICE_CONFIG=iceconfigtest.cfg java -ea -cp $CLASSPATH:. iceconfigtest
    echo Also ok in Python
    env ICE_CONFIG=iceconfigtest.cfg python iceconfigtest.py
    And output from three different machines:

    Code:
    CLASSPATH=xxx/ice-3.3.0.jar ./ice_config.sh 
    Linux gxxx 2.6.18-53.1.14.el5 #1 SMP Wed Mar 5 11:37:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
    java version "1.6.0_06"
    Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
    Java HotSpot(TM) 64-Bit Server VM (build 10.0-b22, mixed mode)
    
    =========================
    Compiling
    Passes with value on command line
    ENV:iceconfigtest.cfg
    Loading: iceconfigtest.cfg
    ICE:me
    Fails without.
    ENV:iceconfigtest.cfg
    ICE:
    Exception in thread "main" java.lang.AssertionError
            at iceconfigtest.main(iceconfigtest.java:24)
    Also ok in Python
    ENV: iceconfigtest.cfg
    Code:
    CLASSPATH=xxx/ice-3.3.0.jar ./ice_config.sh 
    Linux nxxx 2.6.23-gentoo-r8 #2 SMP Tue Feb 19 19:27:38 GMT 2008 x86_64 Intel(R) Xeon(R) CPU X5355 @ 2.66GHz GenuineIntel GNU/Linux
    java version "1.6.0_03"
    Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
    Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-b05, mixed mode)
    
    =========================
    Compiling
    Passes with value on command line
    ENV:iceconfigtest.cfg
    Loading: iceconfigtest.cfg
    ICE:me
    Fails without.
    ENV:iceconfigtest.cfg
    ICE:
    Exception in thread "main" java.lang.AssertionError
            at iceconfigtest.main(iceconfigtest.java:24)
    ...(missing Python)...
    Code:
    CLASSPATH=xxx/ice-3.3.0.jar ./ice_config.sh 
    Darwin jxxx 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386
    java version "1.5.0_16"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-275)
    Java HotSpot(TM) Client VM (build 1.5.0_16-132, mixed mode, sharing)
    
    =========================
    Compiling
    Passes with value on command line
    ENV:iceconfigtest.cfg
    Loading: iceconfigtest.cfg
    ICE:me
    Fails without.
    ENV:iceconfigtest.cfg
    ICE:
    Exception in thread "main" java.lang.AssertionError
            at iceconfigtest.main(iceconfigtest.java:24)
    Also ok in Python
    ENV: iceconfigtest.cfg
    me

  5. #5
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    This is not a bug in Ice. The issue is that you are using Ice.Util.createProperties() (ie with no args) to create the properties in your test. If you take a look at section 38.8.2 of the manual you will see the following:

    "The parameter-less version of createProperties simply creates an empty property set. It does not check ICE_CONFIG for a configuration file to parse."

    Change your test to use Ice.Util.createProperties(args) and you should get the behavior you expect.

  6. #6
    joshmoore is offline Registered User
    Name: Josh Moore
    Organization: Glencoe Software, Inc.
    Project: OMERO, http://trac.openmicroscopy.org.uk/omero
    Join Date
    Feb 2007
    Location
    Germany
    Posts
    110
    Thanks for looking into this, Dwayne.

    It's also possible to comment out the call to createProperties completely and still have the test case fail. It's there for doing the manual loading, but I did test without it.

    Is the expected behavior that ICE_CONFIG will only be checked when command-line-like arguments are explicitly passed into either Ice.Util.createProperties or an initialize method, i.e. not when using something like "Ice.Util.initialize()" If so, would you mind explaining the logic behind this for me? The behavior in Python where:
    Code:
    import Ice
    ic = Ice.initialize()
    does honor ICE_CONFIG seems more natural.

    Thanks again,
    ~Josh.

  7. #7
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    The behavior between python and java is indeed inconsistent. We are discussing internally how this should be fixed. That is, which language should be changed to act like the other. Thanks for bringing this to our attention.

  8. #8
    joshmoore is offline Registered User
    Name: Josh Moore
    Organization: Glencoe Software, Inc.
    Project: OMERO, http://trac.openmicroscopy.org.uk/omero
    Join Date
    Feb 2007
    Location
    Germany
    Posts
    110
    Hi Dwayne,

    just another data point for your discussions. I was surprised that the two print methods returned different values:

    Code:
    import Ice
    
    f = open("cfg","w")
    f.write("omero.host=hi\n")
    f.close()
    
    args1 = ["--Ice.Config=cfg"]
    args2 = list(args1)
    
    id = Ice.InitializationData()
    ic = Ice.initialize(args1,id)
    print "1:",ic.getProperties().getProperty("omero.host")
    
    
    id = Ice.InitializationData()
    id.properties = Ice.createProperties()
    id.properties.parseIceCommandLineOptions(args2)
    id.properties.parseCommandLineOptions("omero", args2)
    print id.properties
    ic = Ice.initialize(id)
    print "2:",ic.getProperties().getProperty("omero.host")
    Reading the manual again, createProperties() is responsible for parsing ICE_CONFIG/Ice.Config, but I continually assume that it's Ice.initialize(), perhaps because of the simplicity of Python's Ice.initialize() doing everything.

    Not a complaint, just pointing out where even Ice regular's can go afoul.
    ~J.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 08-18-2008, 05:11 AM
  2. Unset ICE_CONFIG when running tests
    By Edward Bishop in forum Comments
    Replies: 1
    Last Post: 10-23-2007, 10:22 PM
  3. java:type:java.util.Vector
    By jesse in forum Help Center
    Replies: 1
    Last Post: 04-23-2007, 01:49 PM
  4. Replies: 2
    Last Post: 11-24-2006, 04:03 AM
  5. Replies: 2
    Last Post: 09-18-2006, 06:54 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
  •