Re: Strange problem looks even stranger
Peter Jones <[email protected]> Fri, 17 Nov 2006 18:00:06 -0500
| Newsgroups | gmane.comp.java.sun.rmi |
|---|---|
| Message-ID | <20061117230006.GA15652@east> |
> I ran the program with option -verbose to see which classes are loaded. > More than 700 classes are loaded, which is already a surprise for me. > > Among all those lines reporting loads, I find: > > [Loaded rmisrv.I_Srv from http://localhost:8080/] > > which confirms that the interface for the remote object is loaded (previously, I only saw that it was > sent by the server) > > And my program terminates with: > > Exception in thread "main" java.lang.NoClassDefFoundError: rmisrv/I_Srv > at rmicli.Cli.main(Cli.java:15) I can't say for sure from the information that you have provided so far, but if I gather correctly that "rmisrv.I_srv" is a remote interface and "rmicli.Cli" is your client program, I suspect that you are incorrectly assuming that the remote interface, to which the client program is directly linked, can be dynamically downloaded to the client, as opposed to bundled with or installed with the client program. In other words, I suspect that the successful loading of the interface from http://localhost:8080/ that you see in the -verbose output occurs when the stub for the remote object is unmarshalled, which completes successfully. The NoClassDefFoundError then occurs when your client program attempts to cast the unmarshalled stub to the interface type, which happens to trigger lazy resolution of the client program's symbolic reference to that type-- which fails with a NoClassDefFoundError (a kind of LinkageError) because the client program's defining class loader cannot load the interface (even though the RMI class loader for the codebase could). This incorrect assumption is a common misunderstanding-- see this previous post and others linked from it: http://archives.java.sun.com/cgi-bin/wa?A2=ind0510&L=rmi-users&P=1536 Again, this explanation is just a guess based on the information that you have provided so far. -- Peter =========================================================================== To unsubscribe, send email to [email protected] and include in the body of the message "signoff RMI-USERS". For general help, send email to [email protected] and include in the body of the message "help". For a list of frequently asked RMI questions please refer to: http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html To view past RMI-USERS postings, please see: http://archives.java.sun.com/archives/rmi-users.html