Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.rmi.NoSuchObjectException - At Startup - NOT After Idle Time

800581Nov 8 2009 — edited Nov 9 2009
I'm having the problem above (NoSuchObjectException - no such object in table) at the startup of my RMI server. From everything I've read about this exception it appears to be caused by the remote object being garbage collected after an extended idle period. This is obviously not the case since it's at start up. Even so, I have created a static reference to my server class (the remove object) within the class to stop it from being garbage collected but see no difference. Because of this I'm obviously leaning towards there being a configuration problem (e.g. incorrect codebase) or I'm making a mistake in my code. I'd appreciate any help, thanks.

My server class extends UnicastRemoteObject:
<package and import statements removed>

public class RMIServerStart extends UnicastRemoteObject implements ActionListener {

	private static UnicastRemoteObject thisBoundObject;

	protected RMIServerStart() throws RemoteException {
		super(ServerPreferences.getServerPort());

		try {
			String hostString = "rmi://localhost:"+ServerPreferences.getServerPort()+"/RMIExampleInterface";
			
			if(logger.isDebugEnabled()) {
				logger.debug("hostString: "+hostString);
			}

			thisBoundObject = this;
			
			Naming.rebind(hostString, thisBoundObject); // This is the problem line
		} catch(MalformedURLException murle) {
			logger.error("Error binding interface: "+murle.getMessage(), murle);
			
			System.exit(1);
		}

		<Rest of code removed>
}
The command I'm using to start my server (from command line):
java -classpath libraries\*;RMIServer.jar;. -Dlog4j.configuration=log4jserver.properties -Dsun.rmi.loader.logLevel=VERBOSE -Dsun.rmi.dgc.logLevel=VERBOSE -Djava.rmi.server.codebase=file:/X:/Storage/RMIServer/RMIServer.jar -Xmx2048M rmiserver.RMIServerMain
The Main class just loads some preferences from file then creates a new RMIServerStart instance. Here is the output I'm getting:
X:\Storage\RMIServer>java -classpath libraries\*;RMIServer.jar;. -Dlog4j.configuration=log4jserver.properties -Dsun.rmi.loader.logLevel=VERBOSE -Dsun.rmi.dgc.logLevel=VERBOSE -Djava.rmi.server.codebase=file:/X:/Storage/RMIServer/RMIServer.jar -Xmx2048M rmiserver.RMIServerMain
08-Nov-2009 21:41:08 sun.rmi.transport.WeakRef pin
FINER: main: strongRef = sun.rmi.transport.DGCImpl@79f6f296
08-Nov-2009 21:41:08 sun.rmi.transport.ObjectTable putTarget
FINER: main: add object [0:0:0, 2]
08-Nov-2009 21:41:08 sun.rmi.transport.ObjectTable putTarget
FINER: main: add object [-470e2201:124d5be4c2d:-7fff, 3570801239855135768]
08-Nov-2009 21:41:08 sun.rmi.server.LoaderHandler loadClass
FINE: main: name = "java.rmi.NoSuchObjectException", codebase = "file:/X:/Storage/RMIServer/RMIServer.jar", defaultLoader = sun.misc.Launcher$AppClassLoader@6ba7bf11
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINER: main: class "java.rmi.NoSuchObjectException" found via defaultLoader, defined by null
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINE: main: name = "java.rmi.RemoteException", codebase = "file:/X:/Storage/RMIServer/RMIServer.jar", defaultLoader = sun.misc.Launcher$AppClassLoader@6ba7bf11
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINER: main: class "java.rmi.RemoteException" found via defaultLoader, defined by null
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINE: main: name = "java.io.IOException", codebase = "file:/X:/Storage/RMIServer/RMIServer.jar", defaultLoader = sun.misc.Launcher$AppClassLoader@6ba7bf11
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINER: main: class "java.io.IOException" found via defaultLoader, defined by null
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINE: main: name = "java.lang.Exception", codebase = "file:/X:/Storage/RMIServer/RMIServer.jar", defaultLoader = sun.misc.Launcher$AppClassLoader@6ba7bf11
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINER: main: class "java.lang.Exception" found via defaultLoader, defined by null
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINE: main: name = "java.lang.Throwable", codebase = "file:/X:/Storage/RMIServer/RMIServer.jar", defaultLoader = sun.misc.Launcher$AppClassLoader@6ba7bf11
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINER: main: class "java.lang.Throwable" found via defaultLoader, defined by null
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINE: main: name = "[Ljava.lang.StackTraceElement;", codebase = "file:/X:/Storage/RMIServer/RMIServer.jar", defaultLoader = sun.misc.Launcher$AppClassLoader@6ba7bf11
08-Nov-2009 21:41:09 sun.rmi.server.LoaderHandler loadClass
FINER: main: class "[Ljava.lang.StackTraceElement;" found via defaultLoader, defined by null
[2009-11-08 21:41:09,000] ERROR   235 [main] main (RMIServerMain.java) - NoSuchObjectException thrown from RMIServerStart: no such object in table
java.rmi.NoSuchObjectException: no such object in table
        at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
        at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
        at sun.rmi.server.UnicastRef.invoke(Unknown Source)
        at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
        at java.rmi.Naming.rebind(Unknown Source)
        at rmiserver.RMIServerStart.<init>(RMIServerStart.java:89)
        at rmiserver.RMIServerMain.main(RMIServerMain.java:52)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 7 2009
Added on Nov 8 2009
10 comments
839 views