Hi Steffen,
Thank you for your response.  I found that there is indeed a bug fro this
problem reported for the SUN JDK.  You can view it at:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4744405

It also seems that this bug has not yet been solved.  Its status is in
progress

This is a short version of the bug report:
Bug ID:  4744405  
Votes  17  
Synopsis  RFE: lookupPrintServices() to refresh the printers list
dynamically  
Category  java:classes_2d  
Reported Against  1.4 , 1.4.1  
Release Fixed   
State  In progress, request for enhancement  
Related Bugs  5028849 , 5033703  
Submit Date  10-SEP-2002  
Description  *This also happened on Windows platform.

java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)

When invoke method lookupPrintServices() on class PrinterJob or
PrintServiceLookup, the printers list can not refreshed when adding or
deleting printers dynamically.

Steps to follow to reproduce the problem:
 1. Compile and run the included test case
 2. The print dialog shows up and avaible printers information is printed
out on screen. Click "cancel" to dismiss the dialog. The test case is
pending.
 3. Use Printer Selector Tool to add a new printer into selected printers
list and save changes.
 4. Back to the terminal that run the test case an click "enter" button to
continue. Then a new thread will be created to invoke the
lookupPrintServices() and pop up the print dialog again.
 5. The screen output shows that invoking lookupPrintServices() doesn't
reflect the newly added printer information, neither does the print dialog.

//-------- source code begin-----------//
import java.awt.print.*;
import javax.print.*;

public class MTPrinterTest extends Thread {
    public static void main(String[] args) {
        MTPrinterTest t1 = new MTPrinterTest();
        t1.start();
        
        try {
            System.in.read();
        } catch (Exception e){}
        
        MTPrinterTest t2 = new MTPrinterTest();
        t2.start();
    }
    public void run() {
        PrinterJob printerJob;
        PrintService[] printServices;

        printerJob = PrinterJob.getPrinterJob();
        printServices = printerJob.lookupPrintServices();
        System.out.println("Number of servies found: " +
printServices.length);
        for (int i =0; i< printServices.length; i++)
            System.out.println("--> Available Printer " + i + ": " +
printServices[i]);
        printerJob.printDialog();    
    }  
}
//-------- source code end ----------//
 
Work Around  Exit the current running application and run it again, then the
printers list get refreshed. Seems the running JVM can not get updated
printer information


-----Original Message-----
From: Steffen Heil [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 15, 2004 8:25 AM
To: 'Tomcat Users List'
Subject: AW: Servlet caching?

Hi

> If I write a java program to list the services and run the program from
the command line, I can see the newly added service right away.

Modify your program to list the services, wait one minute, list the services
again.
Install a printer in that time.
See, if the application reflects that change. If not, the Lookup is caching
information.

Regards,
  Steffen


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to