jaspernewuser Posted August 20, 2008 Share Posted August 20, 2008 Hi,I am trying to pring jasper report. But not able to do am getting following errornet.sf.jasperreports.engine.JRException: java.awt.print.PrinterException: Printer is not accepting job.JRPrintServiceExporter.java:253)JasperTest.java:69)JasperTest.java:30)java.awt.print.PrinterException: Printer is not accepting job.RasterPrinterJob.java:1230)JRPrintServiceExporter.java:248 Exception in thread "main"at net.sf.jasperreports.engine.export.JRPrintServiceExporter.exportReport(at test.JasperTest.testPrinting(at test.JasperTest.main(Caused by:at sun.print.RasterPrinterJob.print(at net.sf.jasperreports.engine.export.JRPrintServiceExporter.exportReport( Bellow)below is my code JasperDesign jasperDesign = JRXmlLoader.load("C:\MySQLEmployeeReport.jrxml"); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); Class.forName("com.mysql.jdbc.Driver"); Connection jdbcConnection = DriverManager.getConnection("jdbc:mysql://ao-in003024/ris", "risuser", "password123"); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, jdbcConnection); PrintService pp = PrintServiceLookup.lookupDefaultPrintService(); JRExporter exporter = new JRPrintServiceExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, pp.getAttributes()); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.FALSE); exporter.exportReport(); and if I am using false);I get following error net.sf.jasperreports.engine.JRException: No printer available.JasperPrintManager.java:241)JasperTest.java:48)JasperTest.java:31 )any idea why is it happening so Thanks in advance; JasperPrintManager.printReport(jasperPrint, Exception in thread "main"at net.sf.jasperreports.engine.JasperPrintManager.printReport(at test.JasperTest.testPrinting(at test.JasperTest.main( Link to comment Share on other sites More sharing options...
swood Posted August 22, 2008 Share Posted August 22, 2008 This is not related to JasperServer, but your own code and environment.This method of printing to a printer uses the Java AWT printing functionality. If you search on the web, this is a seemingly random problem that happens under Java 5 and Java 6, but not Java 1.4. ie forums.sun.com/thread.jspa If this is happening all the time, then there is something else wrong. There seem to be many reasons. Google "PrinterException: Printer is not accepting job" to see if there is a solution. ShermanJaspersoft Link to comment Share on other sites More sharing options...
jaspernewuser Posted August 22, 2008 Author Share Posted August 22, 2008 Hi sherman, First thanks for your quick reply. I tried other way of printing. below is my codeJasperDesign jasperDesign = JRXmlLoader.load("C:\MySQLEmployeeReport.jrxml");JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);Class.forName("com.mysql.jdbc.Driver");Connection jdbcConnection = DriverManager.getConnection("jdbc:mysql://localhost/mydb", "mydbuser", "mydbpassword");JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, jdbcConnection);jdbcConnection.close();JasperPrintManager.printReport(jasperPrint, false); an am getting no printer available error, even though a driver is installed for network printer and this printer is in working condition (I tested it) .. Am i missing some steps in above sample code ?Exception in thread "main"net.sf.jasperreports.engine.JRException: No printer available.JasperPrintManager.java:241)PrintServiceApp.java:38) at net.sf.jasperreports.engine.JasperPrintManager.printReport(at test.PrintServiceApp.main( Link to comment Share on other sites More sharing options...
rbojja Posted September 18, 2008 Share Posted September 18, 2008 hey did you get the solution.i am also facing the same issue. please help me if you have any solution Link to comment Share on other sites More sharing options...
CaptnTony Posted February 5, 2009 Share Posted February 5, 2009 I just ran into this problem myself (not using Jasper reports, but printing a pdf file from java).I looked all over for 2 full days and finally found a post that reminded me to keep it simple. This error seems to be very common after 1.4.2 of the jre (1.5+). I tried every idea I found (hacks/tricks, printing to a different flavor of Doc...) and nothing worked. Finally I decided to check my assumptions. I *assumed* that since 'everything else' printed to this printer just fine (and I've printed from iReport to it just fine numerous times) that the printer setup was correct. The first thing I checked on the printer setup was driver version. I found ou that the files I installed from the print server were from way back in 2000 and 2001. The newest on HP's site were from Apr-2008. Long story short. I'm now printing to the printer from within java w/o any issues.Hope this helps. Link to comment Share on other sites More sharing options...
glennodickson Posted February 26, 2010 Share Posted February 26, 2010 Hi I woudl ike to confirm that this code resides somewhere in a JSF backing bean or alike but not a directly coded into in a jsp/jsf page? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now