This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

runtime.exec()

 
gireesh sivan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am facing a problem in linux.

When i try to excecute a shell script using runtime.exec(),the script not exce cutting properly.The process is not completing.i am using jboss as application server.so the call for shell script is from jboss server.so i think jboss server is the problem here

because When i try to excecute script dirctly from linux,it working correctly .Also i try it using stand alone java class.Its working fine.

please help me to find a solution
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... the script not exce cutting properly.The process is not completing.

Can you please explain exactly what you mean by this? What is happening? Does the script get called at all or not? Do you get an error message? If yes, then what is the error message?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i am using jboss as application server.so the call for shell script is from jboss server.so i think jboss server is the problem here

Do you mean you are calling Runtime.exec() from an EJB?
 
gireesh sivan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i try to call runtime.exec(),the process will start and is not completing.i can see the process id.when i shutdown my jboss server,the process wiil complete.

eg: i am calling an shell script called uafimail.sh

the process will start i can see the process id of uafimail.sh.

when i shutdown my jboss server the process will complete.

Its only happends when the call is from jboss server.


i can excecute it from a standalone java program,also from linux prompt.

but the problem when its in jboss
 
gireesh sivan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no the call is not from ejb
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The process is not completing.


That sure sounds like the typical problem you get if you do not provide for consuming the error output stream and standard output stream from the Process. Read the JavaDocs for java.lang.Process - where you will find a discussion of the problem.

Bill
 
gireesh sivan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i also provide error output stream and output stream.

But the problem still remaining
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i also provide error output stream and output stream.

How are you reading those streams? Each stream must have a reader in its own thread, you can't just read one and then the other in the same thread.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic