Shutdown embedded OpenEJB gracefully

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Shutdown embedded OpenEJB gracefully

Markus Lutum
Hi out there.
I am using OpenEJB 3.1.4 the embedded way and need a way to stop the server gracefully.
I start it via:
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
properties.setProperty("openejb.embedded.remotable", "true");
properties.setProperty("openejb.configuration", openEjbBase+File.separator+"conf"+File.separator+"openejb.xml");
properties.setProperty("openejb.home", openEjbBase);

// and start it
InitialContext localContext =  new InitialContext(properties);


localContext.close() does not work


Background:
Our plan is to start and stop the openejb system on demand. It hosts a configuration Backend which is not needed all the time.
We are running this on a 256MB embedded device so if possible we have to save the memory :-)...
For this I have created a handler which starts a new java VM Process (Runtime.exec) with a main method which contains the above code.
Killing the process is not really a good option or?

So is there a remote accessible service which allows me to shut down openejb?
If only doable from inside the container what if I monitor the filesystem for a special marker file via a singleton service and if available start the shutdown process.

So any ideas to "kill" the server would be helpful.
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown embedded OpenEJB gracefully

Jacek Laskowski-2
On Tue, Sep 20, 2011 at 9:11 AM, Markus Lutum <[hidden email]> wrote:

> localContext.close() does not work

Send the "stop" command to the running instance. I don't have a code
to support the idea, but that's how command line works and that's how
I'd assume the code of yours could. But hey, you don't have to run the
command interface for openejb remoting to work (I believe). Sorry for
throwing it all up at you with no code support.

Jacek

--
Jacek Laskowski
Java EE, functional languages and IBM WebSphere - http://blog.japila.pl
Warszawa JUG conference = Confitura (formerly Javarsovia) :: http://confitura.pl
Reply | Threaded
Open this post in threaded view
|

RE: Shutdown embedded OpenEJB gracefully

Markus Lutum
Sending a signal to a process created jy runtime.exec is not an easy thing.
At least because I have to support unix AND windows environments.

But at least I found out that if I set the property
p.put("openejb.embedded.initialcontext.close", "destroy");
then the close will shutdown / undeploy the application and services...

-----Original Message-----
From: Jacek Laskowski [mailto:[hidden email]]
Sent: Dienstag, 20. September 2011 09:24
To: [hidden email]
Subject: Re: Shutdown embedded OpenEJB gracefully

On Tue, Sep 20, 2011 at 9:11 AM, Markus Lutum <[hidden email]> wrote:

> localContext.close() does not work

Send the "stop" command to the running instance. I don't have a code
to support the idea, but that's how command line works and that's how
I'd assume the code of yours could. But hey, you don't have to run the
command interface for openejb remoting to work (I believe). Sorry for
throwing it all up at you with no code support.

Jacek

--
Jacek Laskowski
Java EE, functional languages and IBM WebSphere - http://blog.japila.pl
Warszawa JUG conference = Confitura (formerly Javarsovia) :: http://confitura.pl
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown embedded OpenEJB gracefully

Jacek Laskowski-2
On Tue, Sep 20, 2011 at 9:34 AM, Markus Lutum <[hidden email]> wrote:

> But at least I found out that if I set the property
> p.put("openejb.embedded.initialcontext.close", "destroy");
> then the close will shutdown / undeploy the application and services...

Good catch! I didn't know that. How did you find it out?

Jacek

--
Jacek Laskowski
Java EE, functional languages and IBM WebSphere - http://blog.japila.pl
Warszawa JUG conference = Confitura (formerly Javarsovia) :: http://confitura.pl
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown embedded OpenEJB gracefully

Romain Manni-Bucau
OpenEJB is famous
http://blog.jonasbandi.net/2009/06/restarting-embedded-openejb-container.html
 ;)

- Romain

2011/9/20 Jacek Laskowski <[hidden email]>

> On Tue, Sep 20, 2011 at 9:34 AM, Markus Lutum <[hidden email]>
> wrote:
>
> > But at least I found out that if I set the property
> > p.put("openejb.embedded.initialcontext.close", "destroy");
> > then the close will shutdown / undeploy the application and services...
>
> Good catch! I didn't know that. How did you find it out?
>
> Jacek
>
> --
> Jacek Laskowski
> Java EE, functional languages and IBM WebSphere - http://blog.japila.pl
> Warszawa JUG conference = Confitura (formerly Javarsovia) ::
> http://confitura.pl
>