Go Back   ZeroC Forums > Bug Reports

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 10-19-2008
joshmoore 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: 71
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.
Reply With Quote
  #2 (permalink)  
Old 10-19-2008
joshmoore 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: 71
iceconfigtest.zip
Reply With Quote
  #3 (permalink)  
Old 10-19-2008
dwayne's Avatar
dwayne dwayne is online now
ZeroC Staff
 
Name: Dwayne Boone
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Jan 2005
Location: St. John's, Newfoundland
Posts: 282
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?
Reply With Quote
  #4 (permalink)  
Old 10-19-2008
joshmoore 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: 71
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
Reply With Quote
  #5 (permalink)  
Old 10-20-2008
dwayne's Avatar
dwayne dwayne is online now
ZeroC Staff
 
Name: Dwayne Boone
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Jan 2005
Location: St. John's, Newfoundland
Posts: 282
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.
Reply With Quote
  #6 (permalink)  
Old 10-20-2008
joshmoore 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: 71
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.
Reply With Quote
  #7 (permalink)  
Old 10-20-2008
dwayne's Avatar
dwayne dwayne is online now
ZeroC Staff
 
Name: Dwayne Boone
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Jan 2005
Location: St. John's, Newfoundland
Posts: 282
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.
Reply With Quote
  #8 (permalink)  
Old 02-09-2009
joshmoore 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: 71
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.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Patch #3 for Ice 3.3.0 (C++): compression setting not always honored benoit Patches 0 08-18-2008 04:11 AM
Is the ICE for Java based on Java NIO? Jiangyubao Comments 1 03-30-2008 06:04 PM
Unset ICE_CONFIG when running tests Edward Bishop Comments 1 10-23-2007 09:22 PM
IceV3.11 java client and vc7.0Server : java.lang.NullPointerException? zhoubin Help Center 2 11-24-2006 03:03 AM
Question about ICE_CONFIG environment variable in Ice for java ? rc_hz Comments 2 09-18-2006 05:54 AM


All times are GMT -4. The time now is 07:42 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2009 ZeroC, Inc.