Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

RMI and servlet communication  RSS feed

 
arun sahni
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to call RMI object from servelt. I am using tomcat 4.0.3. I tested the server using command line client , it works ok.
If I place the stub file in std extns or catalina path then it is ok with servlet when servlet is used like RMI client. When I try to download stub file as in client(command line) from server codebase it gives error in servlet file not found. Can anybody suggest how is it possible in tomcat to enable loading of class files from different source? or is ther any other way to use RMI objects in servlet rather then using this aproach?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand your problem correctly, downloading the code requires that the client can make a URL connection to be served the class file. Therefore, another copy of the class file has to be where the server can serve it to a request. There is an example in my servlets book but unfortunately I dont have a copy here.
The Java Enterprise in a Nutshell book has a good chapter on RMI.
Bill
 
arun sahni
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William
Thanks for response. I am using servlet as client to rmi server.
servlet code segment is :
com.hello.DateServer obj = (com.hello.DateServer) Naming.lookup("rmi://localhost/DateServer");
out.println("<br>"+obj.getClass().getName()); (it prints correct stub name which shows it got correct reference from registry)
out.println("<br> date from date server is :"+obj.getDate());
if I place stub file in std extn or catalina path then it works but I want it to download it from URL I given at start of DayServer like :
java -Djava.security.policy=test.policy -Djava.rmi.server.codebase=http://localhost:2002/ DateServerImpl
The http server I have given in codebase is different from servlet.Let me know if you need any additional info.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!