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

NotSerializableException with HTMLEditorKit

XMLWordPrintable

    • b53
    • x86
    • windows_2000

      FULL PRODUCT VERSION :
      java version "1.4.2_08"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
      Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      When trying to serialize a JEditorPane containing a HTML page, we get a NotSerializableException from the HTMLEditorKit


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Open a HTML page with a JEditorPane (setPage Method).
      Send the JEditorPane to a client using Java RMI (or simply try to serialize the JEditorPane)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Since JeditorPane and HTMLEditorKit implement Serializable, there should be no problems
      ACTUAL -
      java.io.WriteAbortedException: writing aborted
      java.io.NotSerializableException

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      error unmarshalling return; nested exception is: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: javax.swing.text.html.HTMLEditorKit$NavigateLinkAction$FocusHighlightPainter java.rmi.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * Created on Apr 19, 2005
       * @author Olivier Picard
       */
      public class SerializeEditorPane {

          public static void main(String[] args) throws IOException {
              
              SerializeEditorPane a = new SerializeEditorPane();
              
              JEditorPane pane = new JEditorPane();
              pane.setEditorKit(new HTMLEditorKit());
              
              pane.setPage(a.getClass().getResource("test.html"));
              pane.setEditable(false);
              
              // just to make sure the EditorPane was loaded correctly
              JFrame frame = new JFrame("TESTING");
              frame.setSize(500, 500);
              frame.getContentPane().add(pane);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.show();
              
              OutputStream outStream = new FileOutputStream(File.createTempFile("test","tmp"));
              
              ObjectOutputStream out = new ObjectOutputStream(outStream);
              out.writeObject(pane);
              out.flush();
              out.close();
          }
      }
      ---------- END SOURCE ----------
      ###@###.### 2005-05-02 05:37:36 GMT

            idk Igor Kushnirskiy (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: