[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1065
  • Last Modified:

RMI: How to Stop RMI Server Thread in a J2EE server?

I am running a servlet in a J2EE server - init() method of this servlet starts a RMI server (I start RMI server programatically using LocateRegistry.createRegistry() and then binding my Server object to this registry) and destroy() method of servlet is meant to clean up whatever RMI server has started/initialized. The problem is I am not able to figure out a way to stop the RMI server thread itself - this is persistent thread and unless this threads exits, destroy() of servlet doesn't exit. So I have two questions:

1. How to make sure that all threads that RMI server would have started to process client requests are through with their execution?

2. And how to stop main RMI server thread programatically?

This would be easier when we run RMI server from a command line, then putting System.exit(0) as the last call cleans up everything but in a J2EE server, it has become tricky.

Thanks.
0
vi_sharma
Asked:
vi_sharma
  • 8
  • 3
1 Solution
 
Giant2Commented:
0
 
Giant2Commented:
And here:
http://access1.sun.com/FAQSets/RMIfaqs.html#23

Both suggest the same solution, so I believe it could be the only one.

Hope this could help you.
Bye, Giant.
0
 
vi_sharmaAuthor Commented:
Giant,

Thanks for the information.
I had looked at these links before posting here.
I can't call System.exit(0) when I am running my application in a J2EE server.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Giant2Commented:
If it's not applicable you can kill the process out of the VM (ps -ax |grep ... and kill it)
0
 
Giant2Commented:
Using Runtime. See here:
http://javaalmanac.com/egs/java.lang/Exec.html?l=rel

Bye, Giant.
0
 
vi_sharmaAuthor Commented:
Giant,

My VM is J2EE's VM, which i can't kill. My application is a servlet which runs in the context of J2EE server - there is no separate VM for my servlet.
0
 
Giant2Commented:
As told before: >...so I believe it could be the only one
0
 
Giant2Commented:
Interested.
0
 
girionisCommented:
So what do you suggest?
0
 
Giant2Commented:
If vi_sharma doesn't find a solution in this time (and no other Experts suggest one), maybe there is no one solution, so my last answer coudl be right.
So I suggest an accept or a delete with points refunds.
0
 
vi_sharmaAuthor Commented:
Well, RMI server had started some other user threads that had to be killed before giving unexportObject(), mentioned in the link.

I am closing this question with points to Giant2 for suggesting the link.
Thanks.
0
 
Giant2Commented:
Thank you.
Bye, Giant.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 8
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now