Results 1 to 3 of 3

Thread: Spring-Server hangs on printing

  1. #1

    Question Spring-Server hangs on printing

    Hello,

    I just face a strange problem. I think its not Spring-related, but I hope that someone could help anyway.

    I have a PdfPrinter-class used by my SaleService which generates Order-Pdfs via iText and then delegates to PdfPrinter which prints files via Ghostscript which works very well in testcase and when printing a file while server-startup...

    When I start my server >>AND PRINT A FILE ON SERVER-STARTUP<< I can invoke the print-method from clients and all files are well printed. I may close and restart one or more clients and can print again without problems...

    When I invoke print() from client while NOT printing a file at server-startup, server and client do hang and nothing is printed...

    The biggest problem. There is no Exception... Nothing... Simply not printing... :-(

    The unknown problem occurs in the line where the printerjob is printed:
    Code:
    job.print(doc, aset);
    when I out-comment this line, the server will obviously not print but it will not hang... So there must be the problem... But as I said, no Exception is thrown...

    here is my implementation of PdfPrinter:
    Code:
    public class PdfPrinter {
    
        public PdfPrinter() {}
        
        public static void printPdf(String filename) {
            
            System.out.println("filename: "+filename);
            Doc doc = new PdfDoc(filename);
            // Gets the format of the document
            DocFlavor flavor = doc.getDocFlavor();
            // Creates a new attribute set
            PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
            PrintService defaultService = 
                  PrintServiceLookup.lookupDefaultPrintService();
            System.out.println("defaultService: "+defaultService);
            //PrintService[] services = PrintServiceLookup.lookupPrintServices(dFlavor, aset);
            DocPrintJob job = defaultService.createPrintJob();
            System.out.println("PrintJob created: "+job);
    
            
            try {
            System.out.println("printing");
                job.print(doc, aset);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    Perhaps there is some serverside printer-init stuff that I missed to enable client-invoked-printing and someone yet had the same problem and could gave me a hint.

    Again. Everything is fine when I print a file on server-startup, but i want to prevent my server from printing a file on every startup to enable printing for clients...

    Thanks for help...

  2. #2
    Join Date
    Nov 2005
    Location
    Chicago
    Posts
    122

    Default

    Try generating a stack dump for all threads. This can be done in the JVM window on Windows w/Ctrl-Break or on UNIX/Linux w/Ctrl-\. Or I think it's the QUIT signal on UNIX. Also, you can start the JVM with the remoting monitoring enabled (see the jconsole man page for details) and you can obtain thread states from that. You should be able to see where the thread is blocked and go from there.

    Jess

  3. #3

    Default

    Not sure but I encountered server printing problems in the past. It was very bizzare and the exceptions were squelched (in Sun JVM). It had nothing to do with Spring.

    Try -Djava.awt.headless=true on your server's JVM.

    ... just a shot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •