java.lang.NullPointerException

JDK Bug System | Roger Yeung | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    FULL PRODUCT VERSION : java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Linux d610 2.6.16.27-0.6-default #1 Wed Dec 13 09:34:50 UTC 2006 i686 i686 i386 GNU/Linux A DESCRIPTION OF THE PROBLEM : I have some XSLT stylesheets that compile and run fine in Java 5, but are failing in Java 6 with exceptions like this: java.lang.NoSuchFieldError: acting$dash$user at GregorSamsa.main$dash$nav() at GregorSamsa.template$dot$28() at GregorSamsa.applyTemplates5() at GregorSamsa.template$dot$15() at GregorSamsa.applyTemplates() at GregorSamsa.applyTemplates() at GregorSamsa.transform() at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:602) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:711) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313) or java.lang.NullPointerException at com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase.getDocumentRoot(DTMDefaultBase.java:1611) at com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBaseIterators$RootIterator.setStartNode(DTMDefaultBaseIterators.java:713) at com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex$KeyIndexIterator.init(KeyIndex.java:805) at com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex$KeyIndexIterator.setStartNode(KeyIndex.java:747) at GregorSamsa.topLevel() at GregorSamsa.transform() at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:602) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:711) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313) While trying to find the source of the problem, I think the problem might narrow down to the way I have some XSLT files which use <xsl:import> to import multiple other files, sometimes importing the same file more than once, eg. root.xsl imports import1.xsl and import3.xsl while import1.xsl also imports import3.xsl, and in import3.xsl it defines a global variable (like $acting-user, from the first exception message). The XSLT validates without error using XSLT validation applications, and runs without error in Java 5. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : I haven't been able to find exaclty the problem, so the easiest way for me to describe how to reproduce is to download the affected application from http://downloads.sourceforge.net/malbum/matte-0.5.0-livedemo.tbz2?modtime=1173708370&big_mirror=0 This is a stand-alone webapp which you can easily reproduce these two exceptions by starting the application (with ./start.sh or .\start.bat), then going to http://localhost:8080/matte/add.do http://localhost:8080/matte/home.do The XSLT files used by these two URLS are located at apache-tomcat/webapps/matte/WEB-INF/xsl/upload-media.xsl apache-tomcat/webapps/matte/WEB-INF/xsl/home.xsl You can get a sample of the XML being used in the transformation by adding log4j.logger.magoffin.matt=DEBUG to the apache-tomcat/webapps/matte/WEB-INF/classes/log4j.properties file, restarting the application, and looking in the apache-tomcat/logs/catalina.out log file. This will log the XML being used in each request. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The XSLT should transform without error (try the same stpes with a Java 5 JRE) and return the transformed XHTML. ACTUAL - An exception is thrown. ERROR MESSAGES/STACK TRACES THAT OCCUR : java.lang.NoSuchFieldError: acting$dash$user at GregorSamsa.main$dash$nav() at GregorSamsa.template$dot$28() at GregorSamsa.applyTemplates5() at GregorSamsa.template$dot$15() at GregorSamsa.applyTemplates() at GregorSamsa.applyTemplates() at GregorSamsa.transform() at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:602) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:711) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313) or java.lang.NullPointerException at com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase.getDocumentRoot(DTMDefaultBase.java:1611) at com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBaseIterators$RootIterator.setStartNode(DTMDefaultBaseIterators.java:713) at com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex$KeyIndexIterator.init(KeyIndex.java:805) at com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex$KeyIndexIterator.setStartNode(KeyIndex.java:747) at GregorSamsa.topLevel() at GregorSamsa.transform() at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:602) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:711) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- The source code is included in the webapp application as described above. ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Use Java 5. Release Regression From : 5.0u10 The above release value was the last known release where this bug was not reproducible. Since then there has been a regression.

    JDK Bug System | 1 decade ago | Roger Yeung
    java.lang.NullPointerException
  2. 0

    xsl:variable with xsl:key crashing in Java 6

    Oracle Community | 8 years ago | 843834
    javax.xml.transform.TransformerException: java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase.getDocumentRoot()
    2. Java RT
      DTMDefaultBase.getDocumentRoot
      1. com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase.getDocumentRoot(DTMDefaultBase.java:1611)
      1 frame