Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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
 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Extend UnicastRemoteObject or use exportObject. Not both
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • 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.
    Bookmark Topic Watch Topic
  • New Topic