im ins strugle with a strange Problem. i have written an dll (as addin for Navision) which calls an console application throu process.start(). The console application using IKVM to use pdfbox.net (v1.8.4).
if i run the console application directly (using cmd or "start" in visual studio) everything works fine. If i start the console app throu process.start() from the class libary (tested with unit test (mstest)) or any other (test-) project i get an exception:
javax.xml.parsers.FactoryConfigurationError: Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl not found
My process.start from the class lib:
string[] args = {pdfFilePath, zugferdFilePath};
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = exeFile,
Arguments = string.Join(" ", args),
WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
ErrorDialog = true,
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false
};
Process process = Process.Start(processStartInfo);
Details about the exception: Message:
Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl not found
Source:
IKVM.OpenJDK.XML.API
StackTrace:
((java.lang.Throwable)_exception).StackTrace " bei javax.xml.parsers.DocumentBuilderFactory.newInstance() bei Mustang.ZUGFeRDImporter.parse() in C:\GIT\KCorp.NAV.Zugferd\KCorp.Nav.Zugferd.Split\Mustang\ZUGFeRDImport.cs:Zeile 124. bei KCorp.Nav.Zugferd.Split.Zaumzeug.showZUGFeRD(String filepath,String xmlFilePath) in C:\GIT\KCorp.NAV.Zugferd\KCorp.Nav.Zugferd.Split\Zaumzeug.cs:Zeile 30."
Does anybody have an idea how to fix this?
If you need further information please let me know.
thanks in advance.
It's a classloader problem. Try adding the following before the line you call the factory:
var s = new com.sun.org.apache.xerces.@internal.jaxp.SAXParserFactoryImpl();
This will force the assembly to load and has worked for me every time I've encountered this problem.