Printing from Java - the print jobs hangs forever
I have a server side printing function, called from Tomcat on Windows 2008 server, that prints on the default printer in this case, and it hangs forever. This is the stack trace:
at sun.awt.windows.WPrinterJob._startDoc(Native Method)
at sun.awt.windows.WPrinterJob.startDoc(WPrinterJob.java:1249)
at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1371)
at com.gnostice.pdfone.PdfPrinter.a(Unknown Source)
at com.gnostice.pdfone.PdfPrinter.print(Unknown Source)
at com.gnostice.pdfone.PdfPrinter.print(Unknown Source)
at de.ikoffice.print.PrintService.printPDF(PrintService.java:64)
at de.ikoffice.document.Document.printPDFToPrinter(Document.java:261)
at de.ikoffice.document.Document.start(Document.java:91)
at de.ikoffice.document.DocumentService.processMessage(DocumentService.java:48)
The culprit is the printer "Microsoft XPS document writer" which seems to open a window in some background shells context (The server is a Tomcat 5.5 running as user Tomcat), and hangs forever there, and I don't know whats the best way to handle the situation.
Any ideas? Hardcoding the printer name and disallowing to print on it? stop()ing 开发者_开发技巧the thread? It's a native function, so I cannot interrupt() the thread with the desired results.
We had a similar issue with a physical printer. From what I read on the web Windows Server 2008 runs services in a special session with no user interface so any pop-up will hang the application.
Can you remove the XPS Writer from the server and use a real printer? Or explicitly check for XPS Writer and not allow the user to print to it?
I've seen mention on the web of various techniques to allow user interaction under WS 2008 but can't say if they are suitable for your application's needs.
精彩评论