I have found the bug number 1883 in the bug database that exectly matches my
problem. It is supposed to be fixed in version 3.3.
Sorry for the trouble.

jacek.


-----Original Message-----
From: Jacek Lawniczek [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 06, 2001 6:46 PM
To: [EMAIL PROTECTED]
Subject: RMI class loading in a servlet (ClassCastException)


Hello everyone,
I have a problem using RMI in a servlet. My configuration is desribed below:
Machine 1:
   - RMI server
   - HTTP server for dynamic class loading.
Machine 2:
   - Tomcat 3.2, my servlet that is an RMI client.

When the servlet is trying to connet to the RMI server, it cannot see all
the classes which are located in WEB-INF/classes directory. This is strange
but it does not cause an error and the client then downloads the neccessary
class files from HTTP server on Machine 1. I can see in the HTTP server log
that the RMI interface, related class and the STUB class are downloaded to
Machine 2.
Unfortunatelly an exception is thrown after I use Naming.lookup to find the
server's instance. I cast the returned Object to my server's interface
(ParkServer) and I get ClassCastException. When I check the Object's class
it shows PackServerImpl_Stub and "PackServerImpl_Stub implements
ParkServer". The code looks like this:

Object o = Naming.lookup("//machine2/park/ParkServer");
// ok
System.out.println("Class=" + o.getClass().getName());
// prints "Class=ParkServerImpl_Stub"
// and this class implements ParkServer interface
ParkServer p = (ParkServer) o;  // exception is raised!!!!

This is very strange to me and I don't know what to do. Please help.

Everything works fine when I put the STUB file in the WEB-INF directory but
it is not the best solution. The the client doesn't download any files from
HTTP server on Machine 1. It takes evertything from WEB-INF/classes.

When I connect to the RMI server from a standalone client everything is OK.
I can also see in the HTTP server's log that only the STUB class is loaded
to the client. This is the right way.

Best regards,
Jacek.


-----------------------------------------------
Wyprawy 2001: Szlakiem Stasia i Nel
http://wyprawy.interia.pl/stasinel2001?aid=9470

Reply via email to