• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI server keeps running in MAC OSX platform but not in Windows XP platform

 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I was trying out the same set of RMI server codes on MAC OSX and Windows XP platform, both using Java 6.

Strangely, in MAC OSX, the server keeps running (in terminal), whereas in Windows, the server starts and stops (in command prompt).

After some googling, it seems that in some cases, the remote object was GCed very soon, and hence the server stops.

Moving the 'service' declaration out of main method (as a static reference) fixed this problem. However, I'm not sure if this is the correct way of solving this problem. Anyone has any comment on this approach?
 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just found out if my remote object extends UnicastRemoteObject, this would not be a problem. Not too sure why
 
Jari Timonen
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Extend UnicastRemoteObject or use exportObject. Not both
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ad,

Like Jari also mentioned it's not necessary to do both: extend from UnicastRemoteObject and use exportObject. I decided to use the exportObject-method (and make it possible in future to let my service implementation class extend from some generic service class).

Ad Tan wrote:Moving the 'service' declaration out of main method (as a static reference) fixed this problem. However, I'm not sure if this is the correct way of solving this problem. Anyone has any comment on this approach?

I did that too, but too solve another issue I experienced. Take a look here for more details.

Kind regards,
Roel
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Ad!

Champion, try the following:



When you call UnicastRemoteObject.exportObject(), you should pass 0 as argument. Maybe that's the problem.
 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jari Timonen wrote:Extend UnicastRemoteObject or use exportObject. Not both
Oooh, sorry wasn't too clear in my posting, in my findings, the 2 methods can be used to launch the server. However, the exportObject method would not allow the server to continue running (the Thread will finish running) unless I put the remote instance in a static variable.

I tried Roberto's suggestion... but no success either.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic