Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5042109

NullPointerException in reading an rtf-file into a javax.swing.text.rtf.RTFEdito



    • Subcomponent:
    • Resolved In Build:
    • CPU:
    • OS:
    • Verification:



        ###@###.### 2004-05-04

        This sure looks like a same bug id #4822283 (same stack trace and the same problem description) which has not been evaluated yet.

        Problem Description from Sun's ISV Software AG:

        To describe a technical problem that occurs when reading an rtf-file into a javax.swing.text.rtf.RTFEditorKit object.

        # Problem description:

        We want to extract the document content from the attached rtf file (probably generated with Word 2002):
        Reading this file into a javax.swing.text.rtf.RTFEditorKit instance fails with a java.lang.NullpointerException.

              (For those in the cc:-list who know in the entire history of this problem: the document content to be returned from the RTFEditorKit object serves as input for Tamino's nonXML-indexer. Because we do not get the content but only the Exception, there is nothing we can write into our index.)

        To ease analysis of this problem we have written a small stand-alone Java program which reads "theDocument.rtf" into an RTFEditorKit object. This fails with a java.lang.NullPointerException in an RTFReader object.

        We compiled and executed this program with java versions "1.4.1_01" and "1.4.2_02", respectively.
        We also tried the "1.5.0-beta" runtime with a class that had been generated with a "1.4.2_02" compiler.
        In all cases we get a stacktrace like this one:

              odessy@PCMGM2 XML PARIS D [181] --> $JDK_ROOT/bin/java -version
              java version "1.4.2"
              Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
              Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
              odessy@PCMGM2 XML PARIS D [182] --> $JDK_ROOT/bin/java TestClass
              Exception in thread "main" java.lang.NullPointerException
                      at javax.swing.text.rtf.RTFReader$StylesheetDestination$StyleDefiningDestination.close(RTFReader.java:914)
                      at javax.swing.text.rtf.RTFReader.setRTFDestination(RTFReader.java:247)
                      at javax.swing.text.rtf.RTFReader.handleKeyword(RTFReader.java:477)
                      at javax.swing.text.rtf.RTFParser.write(RTFParser.java:232)
                      at javax.swing.text.rtf.AbstractFilter.readFromReader(AbstractFilter.java:105)
                      at javax.swing.text.rtf.RTFEditorKit.read(RTFEditorKit.java:111)
                      at TestClass.main(TestClass.java:42)

        # Our analysis and fix:
        We had downloaded source code from http://wwws.sun.com/software/communitysource/j2se/java2/index.html. Our analysis with this code indicates that our document contains an unknown stylesheet definition. Handling of such unknown stylesheet definitions runs into a piece of code in RTFReader.java that should never be entered (according to the source code documentation).

        We were looking for a fix and found two solutions which allowed us to read "theDocument.rtf" without problems.

            * Fix no. 1:

              With this modified source code the NullPointerException does no longer occur.
            * Fix no. 2:

              We have tried another fix which is much simpler to implement and which also works fine with the given rtf-file, but we are not sure whether this is a valid solution:


        The current status is, that we could copy some classes of the javax.swing.text.rtf package, rename them, and implement one of our fixes in the RTFReader.java source code. However (of course), we are not allowed to do that.

        On the other hand, as long as we do not have a fix for this, we (i.e. Nextance, i.e. Sun) cannot index such documents.
        Do you have any ideas how we can find to a quick fix to this problem?

        I hope you understand our problem, if not or if you have any questions don't hesitate to ask, I'll try to answer asap.

        Best regards,

                Michael Gesmann

        **Business Justification sent from SoftwareAG**

        Nextance/Software AG Critical Issue


        Nextance (www.Nextance.com) provides a Contract Management System. Because of t
        he complex and unstructured nature of contracts, Nextance built their applicatio
        n on top of Tamino, Software AG's XML Data Management system.

        This Issue:

        One of Nextance's largest customers is Sun Microsystems. One deployment of the
        Contract Management System is in Sun's Market Development group. Sun is curren
        tly running a Proof of Concept for a new group. One of Sun's key requirements
        is the storing, managing and quering of RTF documents. Tamino supports non-XML
        documents. However, there are problems storing the RTF documents as required by
        Sun (see 5-3-2004 e-mail from Michael Gesmann, Software AG R&D for full details)
        . This issue is preventing Sun from deploying the Contract Management System.

        The History:

        March 11: Nextance contacted Software AG and logged the issue as Critical in So
        ftware AG's Customer Support Sytem
        April 1: Issue raised at Crisis in Software AG's Customer Support Sytem
        R&D was able to isolate the problem to java code
        Developed a work-around, but the work-around violated Java licensing
        April 7: Contacted Sun Alliance Management
        Needed to locate right Java contact to address the issue
        April 19: Sun Java legal contact identified
        Bill Lard identified at the legal contact, discussions started
        April 30: Call with MDE to identify how to address the issue
        Must funnel all discussions with Sun Product Management through Market Developme
        nt and Market Development Engineering (MDE)
        May 3: Software AG provided details of problem and proposed work-around to MDE

        The Bottom Line:

        Because this issue is impacting Software AG's best Global Alliance partners (Sun
        ) and one of Software AG's best Technology Partners (Nextance), we are pushing t
        o get this resolved ASAP. When resolved, Sun will be able to deploy their syste
        m into production.


            Issue Links



                idk Igor Kushnirskiy (Inactive)
                duke J. Duke (Inactive)
                0 Vote for this issue
                0 Start watching this issue