Hi, im a newbie to the world of ejbs and i have a slight problem. Context jndiCntx = new InitialContext(); jndiCntx.lookup(objectName); I can access and use an ejb using the previous code, but to do so i have to use "-Dorg.omg.CORBA.ORBInitialHost=HostName" on the command line. Is there any way if setting this value from within the code ? Any help, pointers to examples would be most appreciated.
Hi,cheers for the reply Im using the J2EE RI application server. The code Properties props=new Properties(); props.put("java.naming.provider.url","iiop://HostName:1050"); props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory"); // does this do anything ? props.put( "org.omg.CORBA.ORBInitialHost","HostName"); InitialContext jndiCntx = new InitialContext(props); jndiCntx.lookup(objectName); works fine if i specify the "-Dorg.omg.CORBA.ORBInitialHost=HostName" param on the command line. I get the error below if i dont specify the param. javax.naming.CommunicationException: Can't find SerialContextProvider As my class is eventualy going to be part of a bigger project though, i cant use the command line params so i need to be able to set the above value in code. Cheers. ;-)
Did you try to change this line of code from ("java.naming.provider.url","iiop://HostName:1050"); to ("java.naming.provider.url","iiop://Dorg.omg.CORBA.ORBInitialHost:1050"); According to what you described, this should work.
I think you have to give javax.naming. instead of java.naming as the naming package is in javax package. It is always best to import than to give the fully qualified class. Atleast the compiler will throw an error if it is not able to locate a package in import statement. Also the Context class is also in javax.naming package HTH
Hi, cheers for all the help. Ive changed lots of code but i am still having the same problem. im importing javax.naming.*; Ive changed the properties file i use to initialize my context about a million times. Nothing works. However, if i specify the "-Dorg.omg.CORBA.ORBInitialHost=HostPC" to the java command it all works fine. With this param i dont have to set any of the properties in the initialize of the context. All i relay need to be able to do is set whatever the above is from within my code, then every thing should be hunky dory. Cheers ;-)
Problem has become interesting. Can you post your code. I am not sure which directory service you are using and if at all it will require any other downloads if you will post your code.
This doesn' work either. String objectName="cheese"; System.out.println(System.setProperty("org.omg.CORBA.ORBInitailHost","HostName")); InitialContext jndiCntx = new InitialContext(); tempObject= jndiCntx.lookup(objectName); All of the beans and things i have been trying to access have been developed by someone else and there are lots of them deployed and being used on the app server im trying to access.
Just in case anybody cares. the following code works String objectName="cheese"; System.out.println(System.setProperty("org.omg.CORBA.ORBInitialHost","HostName")); InitialContext jndiCntx = new InitialContext(); tempObject= jndiCntx.lookup(objectName); It was the spelling mistake of Initial -> Initail that caused it to not work. Thanks for all the help.
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad: