Skip to main content

GF 3.1.1: using -Dorg.omg.CORBA.ORBInitialHost in JVM invocation works, but "localhost" is used if -D is not present

6 replies [Last post]
KrisFraley
Offline
Joined: 2011-09-08
Points: 0

Please help.

When I specify -Dorg.omg.CORBA.ORBInitialHost in the JVM invocation, standalone client connects to server without any problem. However, I need to be able to specify org.omg.CORBA.ORBInitialHost programmatically. For example,
props.put("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
props.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.setProperty("org.omg.CORBA.ORBInitialHost", "172.16.0.3"); // my remote server is at this IP address
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
...
context = new javax.naming.InitialContext(props);
queueConnectionFactory = (javax.jms.QueueConnectionFactory)context.lookup(connectionFactory);
connection = (Connection)queueConnectionFactory.createQueueConnection(); //EXCEPTION
Using the properties specified above and invoking the JVM without -Dorg.omg.CORBA.ORBInitialHost, yields a connection exception. The exception is telling me that "localhost" is being used, not the IP of the server that my standalone client is trying to reach.
How do I go about overriding the "localhost" default with my [user configurable] programmatic setting??? Can the properties be specified programmatically? Specifying the -D option when invoking the JVM is not an option for us.
Thanks for any help you can provide.
Kris

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
KrisFraley
Offline
Joined: 2011-09-08
Points: 0

I don't know how Yongqin's post got attached to mine, but it has nothing to do with my original question concerning the JVM invocation. I would ask Yongqin to re-enter it as a new topic and for reader's of this post to ignore it.

So far, it looks like a good number of folks have viewed my original post, but I have been the only one to reply. I have read many old posts that are directly related to my original question, but have not seen any solutions to this exact problem. IMO, the apparent requirement to specify the -Dorg.omg.CORBA.ORBInitialHost is very short-sighted. Many folks need to be able to programmatically change the host IP via initial context. It looks to me like this is a bug. Is there a workaround?

Please gurus, I need a fix!

Kris

KrisFraley
Offline
Joined: 2011-09-08
Points: 0

I just tried changing the hosts file on the server, but to no avail. hosts file contained "127.0.0.1 localhost" so I commented that out and added the server's actual IP address and name. Restarted server and client ... same result. Still trying to connect with "localhost" on 3700. Very frustrating. I'm open to try just about anything ... any ideas out there?

Kris

Dipl.-Ing. Tors...
Offline
Joined: 2011-06-28
Points: 0

Set the property org.omg.CORBA.ORBInitialHost on client side as a system property and also in the InitialContext():

System.setProperty("org.omg.CORBA.ORBInitialHost", host);

Properties properties = new Properties();
properties.setProperty("org.omg.CORBA.ORBInitialHost", host);
...
...
Context ctx = new InitialContext(properties);

That works for me with glassfish 3.1.1

To.

On Thu, 29 Sep 2011 07:19:55 -0500 (CDT)
forums@java.net wrote:
> I just tried changing the hosts file on the server, but to no avail.
> hosts file contained "127.0.0.1 localhost" so I commented that out and
>added the server's actual IP address and name.  Restarted server and client
>... same result.  Still trying to connect with "localhost" on 3700.  Very
>frustrating.  I'm open to try just about anything ... any ideas out there?
>
>Kris
>

>
>
>--
>
>[Message sent by forum member 'KrisFraley']
>
>View Post: http://forums.java.net/node/847316
>
>

----
Dipl.-Ing. Torsten Liermann Tel: +49 151/11565077
Theodolindenplatz 2 Fax: +49 89/95449198
81545 München http://liermann-it.de

KrisFraley
Offline
Joined: 2011-09-08
Points: 0

To.,

Thank you for your reply. It works for me too ... much appreciated!

Kris

lztang
Offline
Joined: 2005-10-11
Points: 0

hi,Kris,

Can your stand alone JMS client conect to a remote GF3.1.1 ? My client hung up at new InitialContext().lookup("jms/TestCF") when I set -Dorg.omg.CORBA.ORBInitialHost to the server,it's working if the client and glassfish at the same machine.

Yongqin Xu Guest
Offline
Joined: 2011-09-26
Points: 0

Hello,
I am looking for the way to get native JDBC connetion from the connection wrapper in GF 3.1.1.In tomcat, i know i can do something like:
Class TCJdbcConnectionCls =
cl.loadClass("org.apache.tomcat.dbcp.dbcp.DelegatingConnection");
if (TCJdbcConnectionCls.isAssignableFrom(jdbcConnectionWrapper.getClass()))
{
Method getInnerMostConnection =
TCJdbcConnectionCls.getMethod("getInnermostDelegate", null);
return (Connection)getInnerMostConnection.invoke(jdbcConnectionWrapper, null);
}
jdbcConnectionWrapper is type of java.sql.Connection
How do i that in GF? What native connection type in GF? thanks