File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Using getRuntime().exec() within EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Using getRuntime().exec() within EJB" Watch "Using getRuntime().exec() within EJB" New topic
Author

Using getRuntime().exec() within EJB

Vinoth Selvaraj
Greenhorn

Joined: Jun 07, 2006
Posts: 18
Hi,

Is there any restriction in using getRuntime().exec() within EJB to create a new process. Also, can we create threads from within EJB?

With Regards
Vinoth Selvaraj
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You can do neither.

From the J2EE Spec.:

The enterprise bean must not attempt to manage threads. The enterprise bean must not attempt
to start, stop, suspend, or resume a thread, or to change a thread´┐Żs priority or name. The enterprise
bean must not attempt to manage thread groups.



Calling Runtime.exec() is opening a security hole. Why do you need to do this?
[ December 12, 2006: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Vinoth Selvaraj
Greenhorn

Joined: Jun 07, 2006
Posts: 18
The application in which i am working in, has to invoke a perl script in the remote machine and get the results from a file written by it.

So, please suggest, how to implementt this in EJB module. Or alternatively can we have a web component in the server which will handle this requirement.
Vinoth Selvaraj
Greenhorn

Joined: Jun 07, 2006
Posts: 18
Is there any possibility to implement this requirement from EJB??
Deepa Raja
Greenhorn

Joined: Nov 27, 2006
Posts: 7
In the MDB,
Runtime javaRuntime = Runtime.getRuntime();
Process p = javaRuntime.exec(jobName );
p.waitFor();
return p.exitValue();
This will call your job which is specified. It will work.
But i dont know that it would be a right choice.(Security)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using getRuntime().exec() within EJB
 
Similar Threads
getRuntime question
Runtime .getRuntime(). exec(cmd)
getRuntime().exec()
shell and getRuntime
nio and getRuntime()?