Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic