• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Running Runtime.getRuntime().exec() problem

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic