Re: [Ikvm-developers] problems finding files when calling assembly is not the entry assembly
Brought to you by:
jfrijters
|
From: Jeroen F. <je...@su...> - 2015-06-18 08:17:01
|
In https://github.com/plutext/docx4j/blob/master/src/main/java/org/docx4j/utils/ResourceUtils.java you can see that docx4j uses the thread context class loader to load its own resources and IMO that is wrong. It should use its own class loader to load its own resources. There are two workarounds: 1) Do a Thread.currentThread().setContextClassLoader(null); so that docx4j falls back to a hack it apparently added for an older IKVM version. 2) Use ikvm.runtime.Startup.addBootClassPathAssembly() to add the assembly to the "boot classpath" so that it is visible from the default thread context class loader. Regards, Jeroen > -----Original Message----- > From: Wallace Turner [mailto:wal...@gm...] > Sent: Thursday, June 18, 2015 1:31 > To: ikv...@li... > Subject: [Ikvm-developers] problems finding files when calling assembly > is not the entry assembly > > I'm using docx4j.net <http://docx4j.net/> however after speaking to the > maintaine he suggested posting here. > > > What I have found is it appears the classloader is having problems > finding something(xalan) if you use docx4j.net <http://docx4j.net/> > from a library that is not the executing assembly: > > > > [WARN] org.docx4j.utils.ResourceUtils - Couldn't get resource: > org/docx4j/convert/out/html/docx2xhtml.xslt > [ERROR] org.docx4j.convert.out.common.AbstractExporter - Exception > exporting package > org.docx4j.openpackaging.exceptions.Docx4JException: Exception loading > template"org/docx4j/convert/out/html/docx2xhtml.xslt", > org/docx4j/convert/out/html/docx2xhtml.xslt not found via classloader. > > > If you move the class with the code in it back into the entry assembly > everything works fine. > > Here is a screenshot that I hope demonstrates the problem: > It shows the Class1.cs living in a separate assembly and the error > output. > > http://imgur.com/hJtvwUQ > <https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif> > > > you look at the source for the top level call (ResourceUtils) you will > see a call to java > <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/ > 6-b27/java/net/URL.java#URL> .net > <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/ > 6-b27/java/net/URL.java#URL> .URL > <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/ > 6-b27/java/net/URL.java#URL> url = loader.getResource > <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/ > 6- > b27/java/lang/ClassLoader.java#ClassLoader.getResource%28java.lang.Strin > g%29> (filename); > > > The thread in post instances is the same. Could you please shed some > insight? > > > > > > Regards > > Wal |