Forum How do I...?

Java wrapper in servlet

michiel104
Hi,

I'm using the following to execute prince from Java:
OutputStream os_file = new FileOutputStream("test.pdf");
Prince p = new Prince("/usr/local/bin/prince");
p.setVerbose(true);
p.setDebug(true);
p.setEmbedFonts(false);
boolean b = p.convert("in.html", os_file);


The linux prince script however is never executed. The java code is used in a servlet (on a tomcat app. server where princexml is installed).

Am I missing something?

Kind regards,
Michiel
mikeday
Can you run /usr/local/bin/prince successfully from the command-line? Are there any security permissions on Tomcat that would prevent it from executing external programs? What mechanism are you using to check if the script is actually executing or not?
michiel104
I can run princexml from the command line. So my guess is, it has something todo with the security settings Tomcat forces me to use.

When I stop using prince.jar, but use
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec([i]command[/i]);

it works. I just call the shell script and it works.

Regards,
Michiel
mikeday
Okay, that's helpful, although a bit strange as the Prince JAR is doing something very similar, just calling the exec method that takes an array instead of a single string.