Mohsen Saboorian writes:
> Thanks,
> There was no DomDocumentBuilderFactory entry in the output of command:
> nm --demangle=java myapp.exe
> even when I explicitly imported and did "new
> DomDocumentBuilderFactory()" in the code.
>
> I extracted a portion of libgcj-4.2.0.jar (the whole content of
> gnu.xml.* package), say gcj-dom.jar, and compiled and linked it with
> my application. The result executable has DomDocumentBuilderFactory
> but this time I'm facing with NoClassDefFoundError for
> gnu.xml.dom.DomImpl.
> Again I put the trivial code new DomImpl() and linked the app. This
> time again I'm facing with:
>
> java.lang.NoClassDefFoundError: gnu.xml.dom.DomImpl
> java.lang.Class.initializeClass(zekr_static_olpc.exe)
> gnu.xml.dom.ImplementationSource.<clinit>(zekr_static_olpc.exe)
> java.lang.Class.initializeClass(zekr_static_olpc.exe)
> java.lang.Class.newInstance(zekr_static_olpc.exe)
> org.w3c.dom.bootstrap.DOMImplementationRegistry.newInstance(zekr_static_olpc.exe)
> gnu.xml.dom.DomDocumentBuilderFactory.<init>(zekr_static_olpc.exe)
> net.sf.zekr.engine.xml.XmlReader.<init>(zekr_static_olpc.exe)
> net.sf.zekr.common.config.ApplicationConfig.extractLangProps(zekr_static_olpc.exe)
> ...
>
> It's strange that although there exists some entry for gnu.xml.dom.DomImpl with:
> nm --demangle=java myapp.exe
> it gives me that error.
>
> I should also say that I tried to embed xercesImpl.jar with my app, setting:
> javax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
> so that it uses xerces instead of gnu.xml.*. It gives me again a
> NoClassDefFoundError.
>
> It seems that even when a class file is embedded in a static binary,
> class loader (java.lang.Class.initializeClass()) cannot load that.
I think this is a bug in libgcj. The NoClassDefFoundError is
reporting the wrong missing class. It's actually one of
DomDocumentBuilderFactory's dependencies that isn't being found. If
you use "jcf-dump -v" on the class you'll see what its dependencies
are.
I'm sorry this is turning into such a PITA.
Andrew.