You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Markus Lutum <Ma...@nedap.com> on 2011/09/20 09:11:41 UTC

Shutdown embedded OpenEJB gracefully

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.

Re: Shutdown embedded OpenEJB gracefully

Posted by Romain Manni-Bucau <rm...@gmail.com>.
OpenEJB is famous
http://blog.jonasbandi.net/2009/06/restarting-embedded-openejb-container.html
 ;)

- Romain

2011/9/20 Jacek Laskowski <ja...@japila.pl>

> On Tue, Sep 20, 2011 at 9:34 AM, Markus Lutum <Ma...@nedap.com>
> 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
>

Re: Shutdown embedded OpenEJB gracefully

Posted by Jacek Laskowski <ja...@japila.pl>.
On Tue, Sep 20, 2011 at 9:34 AM, Markus Lutum <Ma...@nedap.com> 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

RE: Shutdown embedded OpenEJB gracefully

Posted by Markus Lutum <Ma...@nedap.com>.
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:jacek@japila.pl]
Sent: Dienstag, 20. September 2011 09:24
To: users@openejb.apache.org
Subject: Re: Shutdown embedded OpenEJB gracefully

On Tue, Sep 20, 2011 at 9:11 AM, Markus Lutum <Ma...@nedap.com> 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

Re: Shutdown embedded OpenEJB gracefully

Posted by Jacek Laskowski <ja...@japila.pl>.
On Tue, Sep 20, 2011 at 9:11 AM, Markus Lutum <Ma...@nedap.com> 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