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

Printing from an applet throws an exception the first time it is tried.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P4
    • None
    • 1.4.2
    • client-libs
    • 2d
    • x86
    • windows_xp

    Description

      FULL PRODUCT VERSION :
      java version "1.4.2_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04) Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)
      and
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      I submitted this bug once before and received a response that it was unreproducible. Since then, I have learned how to reproduce the bug for you. On the Tomcat server, for HTTP status code 404, create a custom error page. Once that is done, you will see the bug I'm describing. The reason the bug occurs is because when you setup a custom error page in Tomcat, the Java Applet receives HTTP status code 200 instead of 404 when requesting the URL "http://<yourservername>/<appletlocation>/META-INF/services/javax.print.PrintServiceLookup". This is described in more detail at http://forum.java.sun.com/thread.jsp?forum=31&thread=448584.

      At the minimum, you should let developers know that there is a printing bug from applets if they have a custom error page setup for HTTP Status Code 404. The workaround is listed in the workaround section.

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      This bug refers to what users are discussing in this Forum thread:
      http://forum.java.sun.com/thread.jsp?forum=31&thread=448584

      An exception is thrown the first time a user tries to print from an applet. Subsequent attempts work. I've tested the code below on IIS 5. It happens over http and https. It happens with a unsigned and also a signed applet.
      The first time a user tries to print, an exception (shown below) is thrown and no print out occurs. Subsequent attempts do not throw any exceptions and print outs are ok. I've tested with both IE and Netscape 7.1 with the same results.
      It looks like this bug started occuring with JRE v1.4.2_04. I had the same problem with 1.4.2_05 and 1.5.0-beta 2.

      I'm running on IIS 5, but other forum posters have the problem on Websphere and Weblogic.

      Here's what shows up in the IIS log when the exception occurs:

      2004-08-16 21:24:26 164.67.133.5 - 164.67.134.160 80 GET /training/PrintTest.class - 304 Mozilla/4.0+(Windows+XP+5.1)+Java/1.5.0-beta2 -
      2004-08-16 21:24:26 164.67.133.5 - 164.67.134.160 80 HEAD /default.htm 404;http://fsw.ais.ucla.edu/training/META-INF/services/javax.print.PrintServiceLookup 200 Mozilla/4.0+(Windows+XP+5.1)+Java/1.5.0-beta2 -
      2004-08-16 21:24:26 164.67.133.5 - 164.67.134.160 80 GET /default.htm 404;http://fsw.ais.ucla.edu/training/META-INF/services/javax.print.PrintServiceLookup 200 Mozilla/4.0+(Windows+XP+5.1)+Java/1.5.0-beta2 -


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use the java code I supplied to create an applet. Click the button to print a page of text. The applet will throw an exception the first time the print button is pressed. Subsequent attempts are fine.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The applet should be able to print on the first attempt.
      ACTUAL -
      Exception is throw.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      This is the trace from 1.4.2_05:
      sun.misc.ServiceConfigurationError: javax.print.PrintServiceLookup: http://fsw.ais.ucla.edu/training/META-INF/services/javax.print.PrintServiceLookup:1: Illegal configuration-file syntax
      at sun.misc.Service.fail(Unknown Source)
      at sun.misc.Service.fail(Unknown Source)
      at sun.misc.Service.parseLine(Unknown Source)
      at sun.misc.Service.parse(Unknown Source)
      at sun.misc.Service.access$100(Unknown Source)
      at sun.misc.Service$LazyIterator.hasNext(Unknown Source)
      at javax.print.PrintServiceLookup$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.print.PrintServiceLookup.getAllLookupServices(Unknown Source)
      at javax.print.PrintServiceLookup.lookupDefaultPrintService(Unknown Source)
      at sun.print.RasterPrinterJob.lookupDefaultPrintService(Unknown Source)
      at sun.awt.windows.WPrinterJob.getPrintService(Unknown Source)
      at sun.print.RasterPrinterJob.print(Unknown Source)
      at sun.print.RasterPrinterJob.print(Unknown Source)
      at PrintTestApplet.actionPerformed(PrintTestApplet.java:41)
      at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
      at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
      at java.awt.Component.processMouseEvent(Unknown Source)
      at java.awt.Component.processEvent(Unknown Source)
      at java.awt.Container.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)

      This is the trace from 1.5.0-beta 2:
      Exception in thread "AWT-EventQueue-2" sun.misc.ServiceConfigurationError: javax.print.PrintServiceLookup: http://fsw.ais.ucla.edu/training/META-INF/services/javax.print.PrintServiceLookup:1: Illegal configuration-file syntax
      at sun.misc.Service.fail(Unknown Source)
      at sun.misc.Service.fail(Unknown Source)
      at sun.misc.Service.parseLine(Unknown Source)
      at sun.misc.Service.parse(Unknown Source)
      at sun.misc.Service.access$100(Unknown Source)
      at sun.misc.Service$LazyIterator.hasNext(Unknown Source)
      at javax.print.PrintServiceLookup$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.print.PrintServiceLookup.getAllLookupServices(Unknown Source)
      at javax.print.PrintServiceLookup.lookupDefaultPrintService(Unknown Source)
      at sun.awt.windows.WPrinterJob.getPrintService(Unknown Source)
      at sun.awt.windows.WPrinterJob.printDialog(Unknown Source)
      at PrintTestApplet.actionPerformed(PrintTestApplet.java:37)
      at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
      at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
      at java.awt.Component.processMouseEvent(Unknown Source)
      at javax.swing.JComponent.processMouseEvent(Unknown Source)
      at java.awt.Component.processEvent(Unknown Source)
      at java.awt.Container.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class PrintTestApplet extends javax.swing.JApplet implements java.awt.event.ActionListener {

          /** Initialization method that will be called after the applet is loaded
           * into the browser.
           */
          public void init () {
      javax.swing.JButton button = new javax.swing.JButton("Click here.");
      button.addActionListener(this);
      getContentPane().add(button);
          }

      public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
      java.awt.print.PrinterJob pj;
      try {
      pj = java.awt.print.PrinterJob.getPrinterJob();
      }
      catch ( Exception ex ) {
      System.out.println(ex.getMessage());
      return;
      }

      java.awt.print.Book book = new java.awt.print.Book();
      book.append(new PrintTest(), new java.awt.print.PageFormat());

      if ( pj.printDialog() )
      {
      pj.setPageable(book);
      try {
      pj.print();
      }
      catch ( Exception ex ) {
      System.out.println(ex.getMessage());
      }
      }
      }

      }

      class PrintTest implements java.awt.print.Printable {
      public int print(java.awt.Graphics g, java.awt.print.PageFormat pageFormat, int pageIndex)
      {
      g.drawString("This is a test", 100, 100);
      return java.awt.print.Printable.PAGE_EXISTS;
      }
      }

      ---------- END SOURCE ----------
      workaround :
      suggested_val :
      cust_name : Ray Shah
      cust_email : ###@###.###
      jdcid : rshah0
      language : English
      keyword : webbug
      company : UCLA / AIS
      hardware : x86
      OSversion : win_xp
      bugtraqID : 0
      dateCreated : 2004-08-16 15:37:20.3
      dateEvaluated : 2004-11-04 15:29:52.187


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      For Tomcat server, modify the custom error page to be a JSP, and force the HTTP status code to be 404. For IIS server, use File access to display the custom error page instead of an URL redirect.
      ###@###.### 2004-12-23 18:35:47 GMT

      Attachments

        Issue Links

          Activity

            People

              jgodinez Jennifer Godinez (Inactive)
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: