NPE in parser->getDOMImplementation() with CNI
Sam Ruby
rubys@intertwingly.net
Mon Jun 22 11:33:00 GMT 2009
Andrew Haley wrote:
> Mark Wielaard wrote:
>> On Sun, 2009-06-21 at 16:46 +0100, Andrew Haley wrote:
>>> Sam Ruby wrote:
>>>> I'm trying to develop a JAXP implementation using CNI, but I get a
>>>> NullPointerException when I try to get a DOMImplementation. I've
>>>> attached a small script (tested on Ubuntu 9.04) which demonstrates the
>>>> problem.
>>>>
>>>> Any help would be appreciated.
>>> Congratulations on this excellent test case. Next time I want to tell
>>> people how to do it right, I'll point them at your posting.
>>>
>>> However, I get
>>>
>>> $ sh ~/testdomimpl.sh
>>> gnu.xml.dom.DomDocumentBuilderFactory@160ecdad
>>> gnu.xml.dom.DomDocumentBuilder@15ffbc45
>>> gnu.xml.dom.DomImpl@15ef0ee5
>>>
>>> gnu.xml.dom.DomDocumentBuilderFactory@2df0bea7
>>> gnu.xml.dom.DomDocumentBuilder@2de03d5f
>>> gnu.xml.dom.DomImpl@2dd0bfdf
>>> $ gcj --version
>>> gcj (GCC) 4.4.0 20090307 (Red Hat 4.4.0-0.23)
>> I get the same with that version of gcj.
>> But on an older gcj installation:
>> gcj (Debian 4.3.2-2) 4.3.2
>>
>> gnu.xml.dom.DomDocumentBuilderFactory@6992f029
>> gnu.xml.dom.DomDocumentBuilder@647a3539
>> gnu.xml.dom.DomImpl@64826fa9
>>
>> gnu.xml.dom.DomDocumentBuilderFactory@17d5dffb
>> gnu.xml.dom.DomDocumentBuilder@12bcf52b
>> java.lang.NullPointerException
>> at java.io.PrintStream.println(PrintStream.java:473)
>
> I found the problem.
>
> There is an implementation of jaxp in /usr/share/java/jaxp-1.3.jar and
> another in /usr/lib/libgcj.so.90. They are not the same version, and
> they are not compatible.
>
> If you link against /usr/lib/libgcj.so.90 then you must compile against
> the version of jaxp in that library.
>
> Do this:
>
> gcjh -cp /usr/share/java/libgcj.jar -d headers \
> org.w3c.dom.DOMImplementation \
> javax.xml.parsers.DocumentBuilder \
> javax.xml.parsers.DocumentBuilderFactory
I still see the problem. Even after I apt-get remove libjaxp1.3-java-gcj.
> I don't think it's possible to override the version of jaxp that's in
> /usr/lib/libgcj.so.90.
I'd be fine using that version... if only it would work.
> Andrew.
- Sam Ruby
More information about the Java
mailing list