• Post Reply Bookmark Topic Watch Topic
  • New Topic

RMI problem - maybe security?  RSS feed

 
Steven Johnson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - I'm working through an OLD RMI example of a chat window, running from an applet and communicating back to the server

(http://webmonkey.wired.com/webmonkey/97/28/index2a.html?tw=programming)

and it runs fine on my own machine -- I can start up several different browser windows (using my sever IP address, not localhost), type in text, and see it show up on all the other chat windows. However, it doesn't work from remote machiines. It looks like the connection is not getting back to the server running on my machine.

I know there is supposed to be some sort of security setting, but I'm not sure how to set it. As I mentioned, this is an OLD example and doesn't cover security save to say there is a way to set it. I checked Sun's documentation, but didn't find what I needed.

Any suggestions - or suggestions for a good tutorial?

thanks,
 
Steven Johnson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It occurs to me that if I'm going to ask for some help I ought to provide some code detailing the problem.

I've got a server that includes this security code as the first lines in the main method:



When run the applet which tries to access the server, I get this error:



So I'm guessing my applet is having trouble accessing the server, but what I don't know is how to set up the secueity in the server? or in the applet? to allow access.

Any suggestions?

Thanks,
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears that the problem is in your Applet - it appears you are trying to create a RMISecurtiyManager inside your Applet's init method. Applets have all kinds of security constraints, usually called the "applet sandbox" - one of these constraints is that applets can't create their own security managers (because this would potentially let the applet override all security checks that keep them in the sandbox in the first place). Remove the code from the applet's init method that's setting the RmiSecurityManager to get rid of the error message you are currently seeing.

There is a RMI tutorial from Sun that uses an applet example that you can refer to.
 
Steven Johnson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the feedback!

Yes, I eventually figured out I wasn't supposed to set up a SecurityManager in an applet. I've made more progress, but I must still be missing something wrt security. I am using a policy that leaves everything open (for testing only, of course) and I find that some clients can run the applet and access the remote methods, and others can't. This is with java enabled on all clients.

I hope I'm doing something wrong, because if RMI is really this flakey i've wasted a lot of work.

Here are the relevant sections of the code I am using for a simple chat server.

When I run it, I do the usual rmi registry command, and start the server with this command:



Does anyone see an obvious blunder?

Thanks,
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... any additional information on why some of the clients are failing?

Are they different platforms - different OS, browser, or JVM version?

Can you post any error messages you are getting?

There are different ways of viewing the "console" where error messages are displayed based on different things - like the browser, whether the Java-Plugin is used, etc. For example, in IE, if you're using the built-in JDK, you would go to "Tools->Sun Java Console" (and you may have to activate this under the "Advanced" tab of "Internet Options"). If you're using a recent version of the Java Plugin, you'll need to right click the "Java Coffee Cup" icon in the taskbar to bring up the console.
 
Steven Johnson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the feedback!

I got the connection working finally. The info on how to view the java Console was a great help, thanks.

I'm seeing some differences between IE and the other browsers I'm testing with, but I'm not going to ask for help on that until I've had some more time to experiment. (I only get abot 30 minutes a day to work this issue, so it takes me a while to get anywhere).

Thanks for all the suggestions!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!