wood burning stoves 2.0*
The moose likes Servlets and the fly likes problem in running exec() from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem in running exec() from servlet" Watch "problem in running exec() from servlet" New topic
Author

problem in running exec() from servlet

shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
Hi , I am using exec() to run external exe from servlet. The exe is a program which converts the Framemaker files having .mif extension to pdf for that it needs the Framemaker running. My problem is i am able to execute the exe but the exe cannot connect to Framemaker. when i execute from eclipse it connects to Framemeker but from Servlet it does not connect. I also tried using exec("cmd /c mif2pdf.exe") but still i have the same problem. can anybody please tell me how to do it.
thanks in advance
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I don't know what "connect to Framemaker" means
shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
connect to Framemaker means it uses the framemaker server to convert the mif files to pdf format. without Framemaker running it cannot convert the file.
shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
here is my code
Runtime rt = Runtime.getRuntime() ;
Process p = rt.exec("c:\\mifpdf\\MIF2PDF Quag033 C:\\mifpdf\\MicroSeqFastFungalPrtcl_Title.mif");
in this MIF2PDF is the exe file which accepts two parameters 1st parameter is the name of the machine where framemaker is running in this case its my local machine Quag033 and the 2nd parameter is the full path of the MIF file.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

When you run it in the servlet, is that also on your local machine?
shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
yes the servlet is on my local machine. i am using the servlet in web application which has its own tomcat.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

which version of Tomcat are you using, and are you using the default permissions?
shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
i am using Tomcat 5.5 and i am using it with default permissions.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

also, have you checked the logs for errors?
shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
yep it gives null pointer exception.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by shashank bezalwar:
yep it gives null pointer exception.


If it's throwing a NullPointerException, it should also be logging the line number where the exception occurs. That should give you a good starting point for debugging.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
forgot to tell you there is no log in tomcat the null pointer exception error is given is my web applications log.
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

IF its throwing NPE than theres some problem in your servlet.
not in your EXE. may be exe doesnt execute at all.

can you post the exception stacktrace?


[Servlet tutorial] [Servlet 3.0 Cook Book]
shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
i am sure that the exe is executing because if i give only file name it prompts me to give full path of file.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

shashank bezalwar,
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see: TellTheDetails.

Telling us that your application is throwing a NullPointerException but not posting the line of code where it's occurring or, at least, posting the stack trace (as you've already been asked to do) so that we can ask you what's on line xxx makes it virtually impossible for us to help you.

Put yourself in our shoes. How would you help someone who asks you what's wrong with a program if it's throwing a NullPointerException?

Try to give us as much relevant information as possible, including code snippets and stack traces.

-Ben
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem in running exec() from servlet