users@glassfish.java.net

InitialContext#lookup() infinite loop

From: <glassfish_at_javadesktop.org>
Date: Wed, 23 Dec 2009 00:46:13 PST

Hello,

I am trying to look up a business interface deployed on Glassfish 2.1.1 from a TestCase class on eclipse.
The server is a Ubuntu 9.10, and the client is a Windows Vista SP2.
Both machines are located on the same LAN, each with Java 1.6.0_17 installed.


I am using the method below to look up my business interface:

public test.bean.TestInterface lookupBusinessRemote() throws MyServiceFailureException {
    final Properties props = new Properties();
    props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
    props.setProperty("org.omg.CORBA.ORBInitialHost", "server.example.com");
    props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

    InitialContext ctx = null;
    try {
        try {
            ctx = new InitialContext(props);
        } catch (final NamingException ex) {
            throw new MyServiceFailureException("Exception while creating InitialContext :" + ex.getMessage(), ex);
        } catch (final RuntimeException ex) {
            throw new MyServiceFailureException("Exception while creating InitialContext : maybe remote service is down : " + ex.getMessage(), ex);
        }

        final Class<test.bean.TestInterface> ifClass = test.bean.TestInterface.class;
        Object ref = null;
        try {
            ref = ctx.lookup(ifClass.getName());
        } catch (final NamingException ex) {
            throw new MyServiceFailureException("Exception while looking up bean " + ifClass.getName() + " : " + ex.getMessage(), ex);
        } catch (final RuntimeException ex) {
            throw new MyServiceFailureException("Exception while looking up bean " + ifClass.getName() + " : maybe remote service is down : " + ex.getMessage(), ex);
        }
        if (ref != null) {
            return (test.bean.TestInterface) PortableRemoteObject.narrow(ref, ifClass);
        } else {
            throw new MyServiceFailureException(String.format("InitialContext#lookup returned null with the JNDI name : %s", ifClass.getName()));
        }
    } finally {
        if (ctx != null) {
            try {
                ctx.close();
            } catch (final NamingException ex) {
                throw new MyServiceFailureException("Failed to close InitialContext : " + ex.getMessage(), ex);
            }
        }
    }
}


What I am doing is essentially no more than "new InitialContext(props).lookup()".
Everything works fine when both my machines are connected to the network.

However, problem arises when I disconnect my server machine from the network,
where stack traces like the following keep getting logged by code INSIDE GLASSFISH,
without any chance of ever catching exceptions myself:

"IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: server.example.com; 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:2783)
        at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2804)
        at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:261)
        at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:274)
        at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:130)
        at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:192)
        at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:184)
        at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:186)
        at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
        at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
        at com.sun.enterprise.naming._SerialContextProvider_DynamicStub.lookup(com/sun/enterprise/naming/_SerialContextProvider_DynamicStub.java)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:409)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:436)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at test.mdb.RemoteCallContext.lookupBusinessRemote(RemoteCallContext.java:70)
        at test.mdb.RemoteCallContextTest.doTest(RemoteCallContextTest.java:74)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
        at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection timed out: connect
        at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:347)
        at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:244)
        ... 37 more
Caused by: java.net.ConnectException: Connection timed out: 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.java:105)
        at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:332)
        ... 38 more


Things get worse when I reconnect my machine to the network,
where tons of exceptions like the following are logged continuously, until eclipse is rendered unresponsive due to flooded console view.


NAM0004: Exception during name lookup : {0}
java.rmi.MarshalException: CORBA COMM_FAILURE 1398079696 Maybe; nested exception is:
        org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 208 completed: Maybe
        at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:271)
        at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:205)
        at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
        at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
        at com.sun.enterprise.naming._SerialContextProvider_DynamicStub.lookup(com/sun/enterprise/naming/_SerialContextProvider_DynamicStub.java)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:409)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:436)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:436)

        snipped literally thousands of SerialContext.java:436 lines...

        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:436)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:436)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at test.mdb.RemoteCallContext.lookupBusinessRemote(RemoteCallContext.java:70)
        at test.mdb.RemoteCallContextTest.doTest(RemoteCallContextTest.java:74)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
        at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 208 completed: Maybe
        at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectionAbort(ORBUtilSystemException.java:2955)
        at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectionAbort(ORBUtilSystemException.java:2973)
        at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doOptimizedReadStrategy(SocketOrChannelConnectionImpl.java:1788)
        at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1263)
        at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 211 completed: No
        at com.sun.corba.ee.impl.logging.ORBUtilSystemException.ioexceptionWhenReadingConnection(ORBUtilSystemException.java:3039)
        at com.sun.corba.ee.impl.logging.ORBUtilSystemException.ioexceptionWhenReadingConnection(ORBUtilSystemException.java:3058)
        at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.nonBlockingRead(SocketOrChannelConnectionImpl.java:2000)
        at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doOptimizedReadStrategy(SocketOrChannelConnectionImpl.java:1713)
        ... 2 more
Caused by: java.io.IOException: End-of-stream
        at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.nonBlockingRead(SocketOrChannelConnectionImpl.java:1989)
        ... 3 more


I have tried setting "org.omg.CORBA.ORBInitialXxx" parameters via the System properties and using "new InitialContext()" without any parameters, but to no avail.
I have tried setting "com.sun.corba.ee.transport.ORBXxx" parameters, but none of them made significant changes; everything ended up with the same gigantic stack traces.


So, my point is, is there any way I can break away from the infinite loop, and gain control of the lookup() method?
More specifically, I want to know ASAP when the remote business interface becomes unreachable. How can I do that?
[Message sent by forum member 'kmiya' (k.miyauchi_at_blanche-conseiller.co.jp)]

http://forums.java.net/jive/thread.jspa?messageID=377091