问题
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
Or depending on situation...
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.
Error occurred during initialization of VM Initial heap size set to a larger value than the maximum heap size
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 Version: 8
- Apache FOP: 2.1
回答1:
This issue seems more like a general Java configuration problem than a specific FOP one:
Error occurred during initialization of VM Initial heap size set to a larger value than the maximum heap size
this means that the initial Java heap size set with the -Xms
option is bigger than the maximum Java heap size requested with the -Xmx
option.
You should check the value of your {maxmemory}
parameter and make sure it is not less than 256m.
回答2:
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.
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
来源:https://stackoverflow.com/questions/36578796/apache-fop-return-code-1-on-pdf-generation