I am reading Thinking in enterprise java, the RMI chapter, and I write a demo to test RMI, here is my code:
it doesn't work ,and the exception is :java.security.AccessControlException: access denied (java.net.SocketPermission HIWAY resolve), when I comment this line: System.setSecurityManager(new RMISecurityManager()); it works well, but at page 42 of Thinking in enterprise java, it said:
When you’re serving
RMI objects, at some point in your program you must:
• Create and install a security manager that supports RMI. The only one
available for RMI as part of the Java distribution is RMISecurityManager.
Question 1 : so why it is wrong when I use RMISecurityManager and work well without RMISecurityManager ?
Question 2: at page 42 ,it said :
1. localhost does not work with RMI. Thus, to experiment with RMI on a single
machine, you must provide the name of the machine. To find out the name of
your machine under 32-bit Windows, go to the control panel and select
“Network.” Select the “Identification” tab, and you’ll see your computer name. In
my case, I called my computer “Peppy.” It appears that capitalization is ignored.
2. RMI will not work unless your computer has an active TCP/IP connection, even
if all your components are just talking to each other on the local machine. This
means that you must connect to your Internet service provider before trying to
run the program or you’ll get some obscure exception messages.
it means I must connect to internet to test RMI, but if I use "localhost" at the end of code: Naming.rebind("rmi://localhost:8090/hello", hello); it also works well ,so why ?
Question 3: in my code, I start RMI in code: LocateRegistry.createRegistry(8090); if I start RMI in command line, like this: start rmiregistry 8090, and commet LocateRegistry.createRegistry(8090); in the code , it failed, exception is :
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
these are my questions, please help me, any help will be appreciated.