• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Service allready bound in registry

 
Daniela Ch
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it right to say that only one instance of the server should be running on the same JVM?
If I try to run another instance on the same JVM, same port, the rebind will throw an exception (because of the port)...
Should I make a test to see if the service is bound in the registry same JVM, different port, using Naming.list("//"+dns)?
/Daniela
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
, the rebind will throw an exception

Isn't rebind supposed to overwrite the object if it already exists in the Registry, so I wouldn't expect an exception to occur.
Mark
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll get a RemoteException if you try to start a new RMI-Registry on the same port and same host.
You'll not get any exception if you just are using rebind(..) when binding a new Server - but if you are using bind(..), and a Server exist in the registry, then you'll get an exception.
Rene
[ December 30, 2002: Message edited by: Rene Larsen ]
 
Daniela Ch
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then maybe I should use bind (instead of rebind) to make sure that only one instance of the server is running?
/Daniela
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, rebind is the preferred method.
Mark
 
Daniela Ch
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then should I make the server a singleton?
Will this be redundant because the server allready extend UnicastRemoteObject?
If I start an instance of the server (default host and port) and start some clients.
The I start another instance of the server using the same defualt values, it will override the service of the first instance...All the clients will throw RemoteError (their service is not in the registry anymore?)
Is this right? should I leave it like this and document it or should I avoid having two instances running?
Naming.list(port) wont help since it lists the services of one specific port...
/Daniela
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I am getting a little confused. I always think of one server running, because I only start one server/RMIRegistry. I can't think of any reason to start a second.
So the rebind is for the ConnectionFactory Class to bind itself into the registry. That's it there is no binding it a second time, no need for Singleton because my code only binds one object.
Mark
 
Daniela Ch
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Me neither, I dont want another server running...
but what if they make this test (running another server when there is allready one running) when they correct my assignement? I dont want all my clients to crash...
should I investigate more into this or should I just say that only one server should be running?
Happy new year!!!
(I spent both my xmas and my new year on this forum huhu)
[ December 31, 2002: Message edited by: Daniela Ch ]
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could have the Server start the RMI-registry, when it starts.

If you try to start a new RMI-Registry on the same port and same host, you'll get a RemoteException.
This mean that you can only have one server running.
Rene
[ January 01, 2003: Message edited by: Rene Larsen ]
 
Jane Wang
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, my problem is that i cannot use any other port number besides 1099. If I use other port number, an exception will thrown to say:

Connection refused to host: 218.244.114.87; nested exception is:
java.net.ConnectException: Connection refused: connect

AND my code is
 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Why are you using "rebind" after all the discussions that were posted on this thread?
check your policy file. Is it possible that you are granting permissions to just one port?
Aruna.
 
Daniela Ch
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok
To fix all my problems I decided to remove the option of entering a host and a port for the server... (chiiickkeennnnnn...) I use localhost and 1099...
But while testing, I discoverd that if I start two servers, (same host same port since I dont allow the user to specify them) the data file will be shared by the two server and none crash...
The clients of server 1 will be able to book and the clients of server2 too...
how can this be?
I think I understand the createRegistry and the bind/rebind...How can one data file be shared by two server? Should I forbit this? should I do something to stop the second instance from running?
 
Daniela Ch
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rene Larsen:
You could have the Server start the RMI-registry, when it starts.

If you try to start a new RMI-Registry on the same port and same host, you'll get a RemoteException.
This mean that you can only have one server running.
Rene
[ January 01, 2003: Message edited by: Rene Larsen ]

But Rene, by doing this my server is monopolizing the RMI registry of this port...Is this bad?
I do this :


If there is allready a registry on this port I use it...
What do you think?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniella.
Don't worry about the assessor trying to start two servers, he isn't going to do that and expect it to work.
What you had originally is fine. You need to allow the assessor to enter the ip/server address to connect to the server, because he will probably have two machines, one for the server and one for the client. If you don't allow him to enter the IP of the server machine, how is he going to connect to it.
Mark
 
Daniela Ch
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
I removed the option of entering a host and a port for the server, not the client.
And since I played with the Naming.list and that I think I understand how it works, I am going to keep the test to see if another server is allready running...
If he tries to run another instance of the server I tell him this :
C:\project>java suncertify.server.ConnectionFactoryServer
The "connectionFactory" service is already bound in the registry.
URL :rmi://localhost:1099/connectionFactory
C:\project>
Thank you all...
daniela (only 1 l)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic