问题描述
我正在尝试使用最新版本的Apache FOP生成PDF.但是,在执行此操作时,返回码出现错误.由于某种原因,它现在在执行过程中返回"1"而不是"0".
I am attempting to use the latest version of Apache FOP to generate PDF's. When doing this however, I am getting an error with the return code. For some reason it is now returning "1" instead of "0" on the process execute.
ProcessBuilder processBuilder = new ProcessBuilder(commandWords);
processBuilder.directory(fopFolder);
processBuilder.redirectErrorStream(true);
StringBuilder outputBuilder = new StringBuilder();
Process process = processBuilder.start();
exitCode = process.waitFor(); //Should return 0, actually returns 1
我要传递的命令字是...
The command words I am passing are...
path -jar fop.jar -c configPath -fo {null} -pdf outputPath
或者根据情况...
path -Xms256m -Xmx{maxmemory} -jar fop.jar -c configFile -fo {null} -pdf outputPath
我后来也设法排除了这个错误,我怀疑这可能是原因.如果我找到自己的解决方案,我将在以后根据需要添加答案.
I also managed to get this error out of it later which I suspect may be the cause. I will add an answer later as required if I find my own solution.
感谢您对此问题的任何建议,如果您需要其他信息,我也很乐意更新我的问题,因为我不确定100%是否需要调试该问题所需的信息.
Any advice on this subject is appreciated, if you require additional information I would also be happy to update my question, as I am not 100% sure what information is required to debug this problem.
- Java版本:8
- Apache FOP:2.1
推荐答案
进一步研究之后,我们正在运行一个tomcat服务器,该服务器反过来又启动了Apache FOP.由于尝试解析的参数不正确,因此内存用完了.
After looking into this further, we are running a tomcat server, which was in turn launching the Apache FOP. It was running out of memory because the parameters it was attempting to parse were incorrect.
我们重新设置,并将以下两个更改作为默认值传递给FOP,并且效果很好.我们认为默认值无效或太低而无法处理.
We redid the setup and instead passed the following two changes to the FOP as default and it worked perfectly. We believe the default was something either invalid or too low to handle the process.
path -Xms256m -Xmx1024m -jar fop.jar -c configFile -fo {null} -pdf outputPath
这篇关于PDF生成中的Apache FOP返回代码1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!