You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by joe <fi...@yahoo.de> on 2010/05/28 15:23:21 UTC

starting a process from a stateless EJB

Hi guys,

Our presentation tier is a swing client. This client shows data mainly 
queried from a database, lets say 90%. But some data are queried from a 
application running on the same machine as the EJB-Container. This 
application is simply invoked like Runtime.getRuntime().exec("app.exe");
and the stdout, stderr is processed.

I know normally an application should not be started from an EJB, but 
for our purposes it would be nice. I implemented a stateless session 
bean invoking an application, and it worked.

Do you think this is ok in this case, or is there any problem, why i 
really shouldn't do it?


Re: starting a process from a stateless EJB

Posted by David Blevins <da...@visi.com>.
On May 31, 2010, at 12:10 AM, joe wrote:

> Am 28.05.2010 19:21, schrieb Andy:
>> You can do anything you want in an EJB, as long as you understand the
>> lifecycle of an EJB. The only question here is if you want to keep hold
>> of the process?
> 
> Nope, just executing a native application, and read the stdout, stderr.
> So i go this way for awhile, thx

On a side note, feel free to grab a copy of this class.  It's super useful for dealing with the stdin, stdout, and stderr of the forked process:

  http://svn.apache.org/repos/asf/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Pipe.java

-David


Re: starting a process from a stateless EJB

Posted by joe <fi...@yahoo.de>.
Am 28.05.2010 19:21, schrieb Andy:
> You can do anything you want in an EJB, as long as you understand the
> lifecycle of an EJB. The only question here is if you want to keep hold
> of the process?

Nope, just executing a native application, and read the stdout, stderr.
So i go this way for awhile, thx





Re: starting a process from a stateless EJB

Posted by Andy <an...@orprovision.com>.
You can do anything you want in an EJB, as long as you understand the 
lifecycle of an EJB. The only question here is if you want to keep hold 
of the process?

If you do, then use a stateful bean. If not then just fire and forget 
the process in a stateless bean. I run a fire and forget process for a 
database backup in postgresql - the same bean has methods to poll the 
external process for state.

However, don't expect the stateful bean to be able to passivate and 
restore the process without some additional code. Also keep clustering 
in mind - not that you will use clustering, but I find it helps govern 
the thought process for the design. Try to make all your beans cluster 
capable.

Andy.