Re: Dynamic Class Loading & AbstractMethodError

Niclas Hedhman <[email protected]>
Newsgroups gmane.comp.java.sun.rmi
Message-ID <[email protected]>
On Monday 17 October 2005 10:51, Miguel Correia Ricardo wrote:
> But the real question is...If i don't put the TaskMessage.class inside
> the directory of server,
> even if this is one of the classes that the rmiregistry doesn't
> download(see point [4]), the client will not work(it complains of
> NoDefClassFoundError) Why? Is it always necessary to duplicate the
> number of classes? One in the customclassloader and in the classpath
> of the server? In this case, the TaskMessage.class has to be in both
> places? Otherwise it will not work?

1. The RMIRegsitry will only download the classes necessary to resolve the
_Stub. That means, interfaces, return types and argument types.


2. TaskMessage is an implementation class of the return type, so that class is
not downloaded by the RMIRegistry (it never sees it), but when the client
calls getTask(), the server will serialize the value (unless it is a Remote
object) of that instance, and transfer to the client, which in turn needs to
load the TaskMessage class in order to deserialize it.

3. I don't think I understand "Is it always necessary to duplicate the number
of classes?". The client only require the classpath to point to the same
classes used to compile the client. The rest can be loaded thru dynamic
classloading.
Furthermore, I think it is easier to only use a single "global" codebase,
which the server uses as well. That means the server starts without any file:
URLs for its classpath, which in turn means that the client will always
receive the same classes.


Cheers
Niclas

===========================================================================
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.