The Artima Developer Community
Sponsored Link

Jini Forum
ClassCastException....need help!!!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
jill

Posts: 1
Nickname: s001058
Registered: Jun, 2002

ClassCastException....need help!!! Posted: Jun 4, 2002 9:05 AM
Reply to this message Reply
Advertisement
Dear all,

I have a problem in the Jini programming when one service A uses
another service B. ClassCastException happens. I've searched for old
messages, but haven't get useful suggestions to my problem.
Need help!!!
Please drop me some lines!!!
Thank you very much!!!!!!!!!!!!!!

Service B: a movie player
Service A: a command controller
Service A needs to use Service B.
__________________________________________________________

A-dl. jar is the downloadable jar file that the client uses.
In A-dl.jar, I've include B.class(for more detail: Movie.class)

A.jar is the jar file that is used for the service
A.jar is NOT include B.class

________________________________________________________________
In Service A:

The interface A.java has a method: void ShowSlids(...)

The remote interface remoteA.java has no methods.

The service AService.java only does the process of getting
proxy,discovery, join, registration.

The proxy AProxy.java implements the method void ShowSlids(...) in
the interface:
public void showSlides(String [] picList, int time) throws
RemoteException{
TestMovie testMovie = new TestMovie();
testMovie.showSlides(picList, time);
}

TestMovie.java is used to look for the Service A(a movie player) and
call the methods in Service A.
________________________________________________________________

In TestMovie.java :
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::
Class[] classes = new Class[] {Movie.class};
ServiceTemplate template = new ServiceTemplate(null, classes,null);
Object si = registrar.lookup(template);
System.out.println(si);
// store current ClassLoader
classLoader thisClassLoader =
Thread.currentThread().getContextClassLoader();
Thread.currentThread().setCont extClassLoader(si.getClass().getClassLoader());
System.out.println("The name of the class is: " +
si.getClass().getName());
System.out.println("MovieProxy classloader = " +
java.rmi.server.RMIClassLoader.getClassAnnotation(si.getClass()));
// HERE'S WHERE YOU DO YOUR THING WITH THE SERVICE
if (si instanceof Movie){
System.out.println("true");
}else{
System.out.println("false");
}

movieService = (Movie) si; <-- - - - - - - - --- -- - - - - error
happens at this point

// restore the ClassLoader
Thread.currentThread().setContextClassLoader(thisClassLoader);

::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::

The output is:

movie.MovieProxy@5fd868
The name of the class is: movie.MovieProxy
MovieProxy classloader = http://192.38.86.72:8080/Movie2705-dl.jar
false
java.lang.ClassCastException: movie.MovieProxy
at commandctrl.TestMovie.lookupMovie(TestMovie.java:167)
at commandctrl.TestMovie.discovered(TestMovie.java:118)
at net.jini.discovery.LookupDiscovery$1.run(LookupDiscovery.java:585)
at java.security.AccessController.doPrivileged(Native Method)
at
net.jini.discovery.LookupDiscovery$Notifier.run(LookupDiscovery.java:566)

___ _____________________________________________________________

Could anybody help me? Please drop me some lines!!!
Thank you very much!!!!!!!!!!!!!!

Best regards,
s001058

Topic: reg javaspaces code from the book Previous Topic   Next Topic Topic: jsp sessions

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use