users@glassfish-samples.java.net

Standalone ejb client

From: Piet Theron <PTheron_at_mhg.co.za>
Date: Fri, 28 Mar 2008 14:26:40 +0200

Hi

I've developed an ejb as well as a stand-alone client that access the
bean. Everything works ok when the client and GlassFish is on the same
box. If I try to access the bean from another server however, then I get
the exception below.

 I've set the properties for the InitialContext as follow (Note:
10.10.70.241 is the remote box where GlassFish is running the client is
running on localhost)

Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
 
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
                                     "com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
 
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");

props.setProperty("org.omg.CORBA.ORBInitialHost", "10.10.70.241");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ctx = new InitialContext(props);

----------------- OR
            
Properties props2 = new Properties();
props2.setProperty("provider.url", "iiop://10.10.70.241:3700");
props2.setProperty("java.naming.factory.initial",
"com.sun.appserv.naming.S1ASCtxFactory");
props2.setProperty("com.sun.appserv.iiop.endpoints",
"10.10.70.241:3700");
InitialContext ctx = new InitialContext(props2);

----------------- OR
            
System.setProperty("org.omg.CORBA.ORBInitialPort","3700");
System.setProperty("org.omg.CORBA.ORBInitialHost","10.10.70.241");
System.setProperty("com.sun.appserv.iiop.endpoints","10.10.70.241:3700")
;

            
The client is however still trying to open the connection on
"localhost"...

Any idea on what I'm doing wrong here?

Thanks
Piet Theron

-------------- Exception


28-Mar-2008 14:12:04
com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType:
IIOP_CLEAR_TEXT; hostname: localhost; port: 3700"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
        at
com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBU
tilSystemException.java:2690)
        at
com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBU
tilSystemException.java:2711)
        at
com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(Soc
ketOrChannelConnectionImpl.java:261)
        at
com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(Soc
ketOrChannelConnectionImpl.java:274)
        at
com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createCon
nection(SocketOrChannelContactInfoImpl.java:130)
        at
com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginReq
uest(CorbaClientRequestDispatcherImpl.java:192)
        at
com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClie
ntDelegateImpl.java:181)
        at
com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientD
elegateImpl.java:325)
        at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
        at
org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69
)
        at
com.sun.enterprise.naming.SerialContext.narrowProvider(SerialContext.jav
a:127)
        at
com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:1
82)
        at
com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:339)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at trafficcontroller.Main.run(Main.java:40)
        at trafficcontroller.Main.main(Main.java:57)
Caused by: java.lang.RuntimeException: java.net.ConnectException:
Connection refused: connect
        at
com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketF
actory.java:347)
        at
com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(Soc
ketOrChannelConnectionImpl.java:244)
        ... 13 more
Caused by: java.net.ConnectException: Connection refused: connect
        at sun.nio.ch.Net.connect(Native Method)
        at
sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)
        at
com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.ja
va:105)
        at
com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketF
actory.java:332)
        ... 14 more