Hi, I am trying to set up a servlet as an rmi client. My rmi server runs on a remote machine. I have the rmi server up and running. Now I am trying to write a servler client to talk to this server which exists on a remote machine. I am developing servlet in my desktop using eclipse and tomcat.
When I try to do a lookup, I get AccessControlException.
How do I solve it ?
Servlet in localhost and RMI server in remote machine. Please help Thanks
It sounds like the user, under which your container is running doesn't have sufficient permissions to access the the network resource in question.
Personally, I wouldn't do this directly in a servlet. I would make the RMI client a plain old Java object that can be instanciated by any interface (command line, servlet, etc...) to have it's methods called. This will make debugging things like this much easier.
Thanks for your response Ben. But based on our requirement, I have to have a servlet for accessing RMI server. I managed to get thru that problem by changing java.policy file in my local machine.
Now, I get another exception, "java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: TestServer_Stub
I believe for this I have to set up a codebase. My server runs in an UNIX machine. I read in an article that place the rmi classes[or jar file with rmi stub etc classes] in a directory which can be accessed via http.
and then use -Djava.rmi.server.codebase property from client side. Has anyone tried this ?
Hi, that second error message looks to be a classpath problem.
Make sure the library containing the stubs is included in the classpath when starting up RMIRegistry. I would recommend just doing a simple set and export of the CLASSPATH before starting up RMIRegistry.
I have displayed the way my registry gets started. This rmi server is in a remote machine.
I have my servlet which runs in my tomcat.
I tried putting the server's stub files etc as jar file in Unix server's public_html directory and setting-Djava.rmi.server.codebase=http://test.xx.com/username/public_html/test.jar in my tomcat's configuration.
Still I get lots of exceptions, Unmarshalling exception etc.