Hi all.
I'm having problems with ClassLoader. I have a RMI client that calls a
RMI server. What I keep getting as an error is a ClassCastException.
This is the code:
Object obj = Naming.lookup(url);
search = (SearchRMI) obj;
And the exception is:
java.lang.ClassCastException
at
com.qspi.client.search.SearchClientRMI.setHost(SearchClientRMI.java:49)
at
com.qspi.client.search.SearchClientRMI.<init>(SearchClientRMI.java:33)
at
com.qspi.client.search.SearchClientFactory.getRMIClient(SearchClientFactory.java:87)
at
com.qspi.client.search.SearchClientFactory.getSearchClient(SearchClientFactory.java:38)
at org.apache.jsp.search_jsp._jspService(search_jsp.java:68)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
...
The client code works flawlessly from a JUnit test.
What I have determined is that the object returned by
"Naming.lookup(...)" is of a RMI ClassLoader. The returned object is a
stub, which implements the SearchRMI, but if it is a different
ClassLoader, I guess it cannot cast. I'm not sure why that isn't failing
in JUint, but it is failing in Tomcat 5.0.x. I'm going to test it on
some other installations I have, but I'd like a good explanation on
ClassLoaders, if someone can enlighten me.
How do others do this? Are there any tutorials for RMI in Servlets?
Nix.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]