You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by TK Banks <sp...@yahoo.com> on 2005/05/28 01:41:51 UTC

function call hanging - Bizarre!

My web application is equipped with a ServletContextListener.  Among other things the contextIntialized() method creates and starts a server object which has as one of it's data members an object that inherits from UnicastRemoteObject (the basic Java RMI server implementation).   conextDestroyed() is supposed to shut my server object down, but my shutdown procedure is hanging in a seemingly impossible way.  Here's the basic structure of the server I'm trying to shutdown:
 
public class MyServer
{
    MyRemoteServer r;
 
    // bla, bla, bla
 
    public class MyRemoteServer extends UnicastRemoteObject implements MyRemoteInterface
    {
        // bla, bla, bla
 
        public void stop()
        {
            System.out.println("PRINT #2");
 
            // bla, bla, bla
        }
    }
 
    public void stop()
    {
        // bla, bla, bla
 
        if(r != null)
        {
             System.out.println("PRINT #1");
             r.stop();
        }
    }
}
 
Invocation of MyServer.stop() is not returning.  The confounding thing is that I see PRINT #1 in catalina.out, but NOT PRINT #2.
 
Some things to note:

   I'm running Tomcat 5.024 on Fedora 2.x

   I can startup and shtudown MyServer without error when I run it from a command-line java application -- I only hit the weird hang when running from within tomcat.

   Neither stop() method is synchronized, so I don't see how this could have anything to do with thread locks.  (There are other methods on both of these objects that are synchronized, but these are not.)

   I've verified that UnicastRemoteObject does NOT have it's own stop method that I'm overriding to some ill end.  In fact I changed the name of MyRemoteServer.stop() to MyRemoteServer.doStop() just to make sure I wasn't getting hammered by some subtle function override behavior that I'm too stupid to fathom.

   It's not obvious that the problem has anything to do with RMI, but that is one unusual property of the inner class MyRemoteServer so I mention it.
So what on God's green Earth could cause a non-synchronous method call to hang before the first line of that method is executed?  Could a corrupt object pointer explain this behavior?  I haven't tried printing out the addresses of the myRemoteServer object at startup and shutdown -- perhaps that would reveal something.
 
Much appreciation to any genius who can propose a theory as to what's going on.
 
Matt


		
---------------------------------
Do You Yahoo!?
 Yahoo! Small Business - Try our new Resources site!