I've been developing a webservice in C# where I have to convert Word docx files to PDF. After searching for a long time I settled on docx4j, a java library, to make the conversion. The .jar file works as expected when I run it from a command line, but when I start it from my C# code through System.Diagnostics.Process I get the following errors:
log4j:WARN No appenders could be found for logger (org.docx4j.jaxb.Context).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
...
WARN org.docx4j.utils.ResourceUtils .getResource line 84 - Couldn't get resource: docx4j.properties
WARN org.docx4j.Docx4jProperties .init line 22 - Couldn't find/read docx4j.properties; docx4j.properties not found via classloader.
The C# code making the call looks like this:
Process javaCall = new Process();
var dir = HttpContext.Current.Server.MapPath("~");
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = "-Xmx2048m -jar \"" + dir + "\\App_Data\\DocxToPDF.jar\" \"" + sourcePath + "\"";
startInfo.FileName = "\"" + System.Configuration.ConfigurationManager.AppSettings["JdkFilePath"] + "\"";
startInfo.UseShellExecute = false;
javaCall.StartInfo = startInfo;
javaCall.Start();
javaCall.WaitForExit();
I've checked the windows security settings on the .jar file and the directory it's in and both are set to full permissions to all users. I don't understand why I get different results from making a manual command line call and one from System.Diagnostics.Process.
I'd really appreciate some help and will provide more info if you need it.
Alright, so that answer turned out to be easier than I expected. By moving the .properties to the same folder as the .jar file instead of them being nested inside the program managed to find them...
I guess I should try the easy fixes first next time, thanks for your time.