• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RMI / connection refused

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Im trying to learn RMI to use it in the scjd. I've created a server and a client but I can't get them to connect to each other. I can get the server to start but I can't get the client to connect to it. I guess I have to set permissions, but how?
Please help!
//tina
 
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just follow the Java RMI tutorial and if you have any problems just paste the errors over here and we will help you out.
 
Tina Ljuslin
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
in the tutorial the say that u should use the command:
java -Djava.rmi.server.codebase=file:/c:\home\ann\public_html\classes/
-Djava.rmi.server.hostname=zaphod.east.sun.com
-Djava.security.policy=java.policy engine.ComputeEngine
I've changed this to:
java -Djava.rmi.server.codebase=file:/c:\home\tina\public_html\classes/
-Djava.rmi.server.hostname=localhost (have tried 127.0.0.1 as well)
-Djava.security.policy=java.policy engine.ComputeEngine
but whatever I try I always get:
ComputeEngine exception: access denied (java.net.SocketPermission host resolve)
java.security.AccessControlException: access denied (java.net.SocketPermission h
ost resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
...
...
What am I doing wrong? (or have I forgotten to do something) I have started the registry (start rmiregistry) and set the classpath.
Can someone help?
//tina
 
Rahul Mahindrakar
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I too had this problem when i started out. what you can do is try commenting out the new SecurityManager line and things will work (for now).
I solved it later on but i have to check out. I will get back later.
 
Tina Ljuslin
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
....don't ask me how or why....but it works now!
now I just have to understand it! ;-)
//tina
 
Rahul Mahindrakar
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats great. Get going and complete your project.
Best of Luck.
 
Tina Ljuslin
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I now have my server working, but when I try to connect my client:
C:\>java -Djava.rmi.server.codebase=file:/c:\scjd\starting/ -Djava.security.policy=java.policy suncertify.client.TestClient localhost
I get the exception:
java.lang.ClassCastException: suncertify.server.FBNServer_Stub
at suncertify.client.TestClient.main(TestClient.java:15)
Does anyone know why?
//tina
 
Tina Ljuslin
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for taking up your time... I found out myself.
In the client I was trying to make an instance of the server class instead of the server interface.
Thanks anyway!
//tina
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I learn RMI from sun toturial . I cannot compile the interface Comppute.java since class Task can not be fund. Any one has met such problem? How do you fix it?
jjjj
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tina Ljuslin:
Hi,
in the tutorial the say that u should use the command:
java -Djava.rmi.server.codebase=file:/c:\home\ann\public_html\classes/
-Djava.rmi.server.hostname=zaphod.east.sun.com
-Djava.security.policy=java.policy engine.ComputeEngine
I've changed this to:
java -Djava.rmi.server.codebase=file:/c:\home\tina\public_html\classes/
-Djava.rmi.server.hostname=localhost (have tried 127.0.0.1 as well)
-Djava.security.policy=java.policy engine.ComputeEngine
but whatever I try I always get:
ComputeEngine exception: access denied (java.net.SocketPermission host resolve)
java.security.AccessControlException: access denied (java.net.SocketPermission h
ost resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
...
...
What am I doing wrong? (or have I forgotten to do something) I have started the registry (start rmiregistry) and set the classpath.
Can someone help?
//tina



I made the following change to ComputeEngine.java and it worked on localhost:
//String name = "//host/Compute";
String name = "Compute";
It seems they should have written the hostname instead of the string "host" in the name...
 
reply
    Bookmark Topic Watch Topic
  • New Topic