This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running Runtime.getRuntime().exec() problem

 
Alan Blass
Ranch Hand
Posts: 156
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I am running Runtime.getRuntime().exec() to run VLC (VideoLan) software within a servlet. The VLC software runs properly. I use it to record a multicast video streaming.

After running this command, the servlet returns to my AJAX call and my webpage loads.

Problem is: Any subsequent HTTP get or post, the server (Apache Tomcat 7) does not respond.

It is only about after 2 minutes, the server responds back to my browser.

Anyone has the same problem with VLC?

Anyone has any suggestions to advice me to investigate further?

All comments welcomed.

Thanks.
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several traps that one can fall into using Runtime.exec() so you should read the 4 sections of http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html and implement all the recommendations. If this fails to solve the problem then posting the code might help.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I wonder what use running a GUI client like VLC is from a servlet? When the user is remote, the GUI will appear on the server machine. Is that the intention?
 
Alan Blass
Ranch Hand
Posts: 156
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Thanks for your replies.

When the remote user wants to start recording, I start VLC on the server and start recording the multicast video. Here is my code:



What could be holding up VLC or tomcat that it stopped responding for 2 minutes?

Many thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps VLC is writing to the std err stream, which you are not consuming. A full buffer would cause VLC to hang.

Also - you are doing this all in the request processing Thread - not a good idea. I would certainly execute all that code in a separate Runnable object using its own Thread.

Bill
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alan Blass wrote:
What could be holding up VLC or tomcat that it stopped responding for 2 minutes?


You have the potential for deadlock on both the process stdout and stderr. You really do need to read the 4 sections of the traps article and to implement all the recommendations.. Added to this, your servlet is not thread safe since you have state stored as instance variables.

Both these are critical flaws.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic