Re: need help about code mobility
Mark Zaini <[email protected]>
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
Thank you very much Gregg for the help,
I made the changes,but I have always
"ClassNotFOundException Class B(remote)"
I put my remote class in the folder remoteclasses on Apache :
Class C{
...
InterfContRis cont;//Interface for my remote service
URLClassLoader ld = new URLClassLoader( new URL[]
{
new URL("http://localhost:80/remoteclasses/")
});
Thread.currentThread().setContextClassLoader( ld );
try{
Class resolved=Class.forName(namecl,true,ld);
cont=(InterfContoRis)resolved.newInstance(); //added
cont.run(); //run is a method of remote class B
}
catch(java.lang.IllegalAccessException e){ //added
e.getMessage(); } //added
catch(java.lang.InstantiationException e){ //added
e.getMessage();} //added*/
}
}
Am I missing any steps?
Thanks a lot.Mark
On Wed, 27 Dec 2006 13:46:38 -0600, Gregg Wonderly <[email protected]>
wrote:
>URLClassLoader ld = new URLClassLoader( new URL[] {
>new URL("http://my.host.com/path/to/file.jar"),
>new URL("http://my.host.com/path/to/dir/")
>});
>
> // Make sure that this thread, in other class loading
> // needs has a reference to the "preferred" class loader
> // for loading remote classes.
> Thread.currentThread().setContextClassLoader( ld );
>
> // Load the class needed and all resolved classes will
> // have view of the 'ld' class loader to resolve any
> // classes not defined locally.
> Class resolved=Class.forName(cls,true,ld);
>
>The use of PreferredClassLoader would be my suggested choice instead of
>URLClassLoader so that you can arrange for your "non-platform" classes to
>always be preferred so that you'll get the right version.
--------------------------------------------------------------------------
Getting Started: http://www.jini.org/wiki/Category:Getting_Started
Community Web Site: http://jini.org
jini-users Archive: http://archives.java.sun.com/archives/jini-users.html
Unsubscribing: email "signoff JINI-USERS" to [email protected]