aspose file tools*
The moose likes Java in General and the fly likes NullPointer in 1.5 NOT in 1.6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "NullPointer in 1.5 NOT in 1.6" Watch "NullPointer in 1.5 NOT in 1.6" New topic
Author

NullPointer in 1.5 NOT in 1.6

Nickolas Case
Ranch Hand

Joined: Apr 26, 2008
Posts: 98
I have a Spring enabled stand-alone app that creates XML documents and transforms them into KML. When I run the application using JRE 1.5, I receive a NullPointerException. If I use JRE 1.6 the program runs like a charm. Even is I use a JRE of 1.6 with a target of 1.5 it runs. Only when JRE is 1.5 does the program fail. A previous version runs on 1.5 OR 1.6 but isn't as Spring intensive.

The NullPointer comes when the XML is normalized or transformed (Taking normalize out just causes the transformer to throw the NullPointer).

Has anyone else had or heard of this type of problem?

I have debugged both versions, all attributes are identical up to the point of calling normalize() on the xml only one throws a NullPointer and one does not.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

It would help to print the stacktrace here.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Nickolas Case
Ranch Hand

Joined: Apr 26, 2008
Posts: 98
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Well, make sure you're using the very last patch release for JDK 1.5, in case it's a bug that was eventually fixed. Otherwise you might try using another DOM implementation besides the built-in one.


[Jess in Action][AskingGoodQuestions]
Nickolas Case
Ranch Hand

Joined: Apr 26, 2008
Posts: 98
I don't believe using a different DOM would matter.

If I ANT build using JRE 1.6 with a target of 1.5 I get no errors. It is only on a box with 1.5 that I get the error.

Was just curious if there is a simple code workaround as I can't just upgrade the JRE in this case.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Nickolas Case wrote:I don't believe using a different DOM would matter.


Are you sure? Cause it sure looks like a bug in that "normalize()" method. A different DOM implementation (or a different JDK, which includes a different DOM implementation) would fix that.
Nickolas Case
Ranch Hand

Joined: Apr 26, 2008
Posts: 98
I tried normalizeDocument() instead of normalize(). Nothing. I even removed normalize() from the code altogether. But my transformer threw the nullPointer instead. There is no normalize() in my transform.
Carey Evans
Ranch Hand

Joined: May 27, 2008
Posts: 225

Could there be a null making it into an attribute value or text node somewhere in the DOM? There may be an extra null check in Java 6's version of Xerces that isn't in Java 5.

If you can't find the null, you could try using downloading and using Xerces 2.9.1, and possibly the latest version of Xalan or Saxon, to see if they have the same logic as Java 6.
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

This looks like a problem more with the XML APIs so moving it to the XML and Related Technologies forum .....


apigee, a better way to API!
 
Don't get me started about those stupid light bulbs.
 
subject: NullPointer in 1.5 NOT in 1.6