Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using getRuntime().exec() within EJB

 
Vinoth Selvaraj
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Vinoth Selvaraj
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any possibility to implement this requirement from EJB??
 
Deepa Raja
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic