users@glassfish.java.net

Problem connecting to a remote SessionBean deployed on Glassfish from Tomcat

From: Wouter van Reeven <wouter_at_van.reeven.nl>
Date: Sat, 21 Oct 2006 02:59:59 +0200

Hi everyone,


Recently I wrote a weblog about how to connect from Tomcat to a SessionBean
deployed on Glassfish. Please see

http://technology.amis.nl/blog/?p=1368

Unfortunately I found that this approach only works when I try to connect from
Tomcat running on the same machine as Glassfish. According to the Glassfish EJB
FAQ, I need to set these parameters

props.setProperty("org.omg.CORBA.ORBInitialHost", <host>);
props.setProperty("org.omg.CORBA.ORBInitialPort", <port>);

and I assume that both <host> is the hostname of the machine that Glassfish is
running on and the <port> is the port that the Glassfish IIOP is listening on
(which defaults to 3700).
However, no matter what I set ORBInitialHost to, creating the InitialContext
goes ok, but when I try to lookup the Remote SessionBean, I always get this
error message in the Tomcat logs

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(ORBUtilSystemException.java:2348)
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2369)
    at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:215)
    at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:228)
    at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:104)
    at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:166)
    at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:156)
    at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:296)
    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.java:110)
    at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:164)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:309)
    at javax.naming.InitialContext.lookup(InitialContext.java:351)
    at web.MyServlet.processRequest(MyServlet.java:47)
    at web.MyServlet.doGet(MyServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused
    at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:356)
    at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:194)
    ... 32 more

In other words, for some reason a JNDI lookup seems to be done on localhost,
rather than the server that Glassfish is running on. Can someone please help me
resolve this issue or tell me what I am doing wrong?


Many thanks in advance.

Wouter van Reeven

-- 
People: "If she weighs the same as a Duck, she's made of wood!"
Sir Bedevere: "And therefore...?"