Skip to main content

Re: Embedded GlassFish clean shutdown and restart

3 replies [Last post]
amyroh
Offline
Joined: 2004-05-06

Use Glassfish.dispose if you don't need this GF instance anymore and you
want all resources to be released.

On 9/26/12 11:39 AM, Harald Wellmann wrote:
> Is it possible to cleanly shutdown and restart Embedded GlassFish
> within the same VM?
>
> This is what I'm doing:
>
> GlassFish glassFish = GlassFishRuntime.bootstrap().newGlassFish(gfProps);
> glassFish.start();
> glassFish.stop();
>
> Now after calling glassFish.stop(), I still see a number of threads
> running, e.g. with name "deployment-jar-scanner",
> "transaction-manager" and some others.
>
> What's the proper way to stop these threads and free all resources
> allocated by GlassFish?
>
> (Tested with GlassFish 3.1.2.)
>
> Best regards,
> Harald

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Harald Wellmann

Am 27.09.2012 02:31, schrieb Amy Roh:
> Use Glassfish.dispose if you don't need this GF instance anymore and
> you want all resources to be released.

I'd already tried that. GlassFish.stop() and GlassFish.dispose() (each
by itself or both in combination) don't seem to make any difference. I
still see the threads running in the debugger.

Best regards,
Harald

mvatkina
Offline
Joined: 2005-04-04

If your app uses/needs ORB, it's not possible - ORB is not designed to
be restarted.

-marina

Harald Wellmann wrote:
> Is it possible to cleanly shutdown and restart Embedded GlassFish
> within the same VM?
>
> This is what I'm doing:
>
> GlassFish glassFish = GlassFishRuntime.bootstrap().newGlassFish(gfProps);
> glassFish.start();
> glassFish.stop();
>
> Now after calling glassFish.stop(), I still see a number of threads
> running, e.g. with name "deployment-jar-scanner",
> "transaction-manager" and some others.
>
> What's the proper way to stop these threads and free all resources
> allocated by GlassFish?
>
> (Tested with GlassFish 3.1.2.)
>
> Best regards,
> Harald

Harald Wellmann

Am 27.09.2012 19:10, schrieb Laird Nelson:
> Guessing they're daemon threads so can't be stopped?
>

Yes, they're all daemon threads. But daemon threads can be stopped like
any other thread, so I don't think that's the point.

If GlassFish starts a number of threads (directly or by creating an
ExecutorService with a thread pool), I'd expect it to join or shutdown
all threads and executors in its shutdown phase.

Otherwise, the next GlassFish instance running in the same VM will
create another thread pool, thus causing a resource leak.

Best regards,
Harald