[英]Printing is not working in tomcat, when i start server with services.msc(From client side we could not print )
I am using JasperReports 1.3.1 to print the report. 我使用JasperReports 1.3.1打印报告。 I am sing eclipse and tomcat for development purpose.
我为了发展目的而唱eclipse和tomcat。
In eclipse, when i run the application, the below code will show the listed printer devices and print button. 在eclipse中,当我运行应用程序时,下面的代码将显示列出的打印机设备和打印按钮。 If i click the print button, the report is printing by selected device.
如果单击打印按钮,则报告将由所选设备打印。
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
printRequestAttributeSet.add(MediaSizeName.ISO_A5);
PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
exporter.exportReport();
Here I am passing jasperPrint as a parameter which i manually construted.Its working good 在这里,我传递jasperPrint作为我手动构建的参数。它工作正常
My problem is: 我的问题是:
I created war file and pasted in tomcat Apache Software Foundation\\Tomcat 6.0\\webapps
directory and started the tomcat by using services.msc . 我创建了war文件并粘贴在tomcat
Apache Software Foundation\\Tomcat 6.0\\webapps
目录中,并使用services.msc启动了tomcat。
At this point, its not displaying the listed printer details and also not printing. 此时,它不显示列出的打印机详细信息,也不显示打印。
I put some logger, I found that, the code is hanging with exporter.exportReport();
我放了一些记录器,我发现,代码挂起了
exporter.exportReport();
after this line code is not executing . 在此行代码未执行之后。 Please suggest me for how to print from client side using jasper
请建议我如何使用jasper从客户端打印
Looks like a access right problem to me. 对我来说看起来像是一个访问权限问题。
Is the printer a network printer? 打印机是网络打印机吗? Then make sure that your Tomcat-Service has access rights to the network.
然后确保您的Tomcat-Service具有对网络的访问权限。 If you start Tomcat as a windows service, Tomcat runs per default as "local system user" and have no rights to access network.
如果您将Tomcat作为Windows服务启动,则Tomcat默认运行为“本地系统用户”,并且无权访问网络。 This would explain that no printer is listed and you can't print.
这可以解释没有列出打印机而且无法打印。 Eclipse is started by you, so the eclipse-process have your rights and can access the network and the printer.
Eclipse是由您启动的,因此eclipse-process拥有您的权限,可以访问网络和打印机。
To change the Tomcat-Service user, go to Windows Services --> Right click on Tomcat Service --> Properties --> Login --> This Account --> Type name/pass from a user that have the right to access the printer over the network (maybe you :) ). 要更改Tomcat-Service用户,请转到Windows服务 - >右键单击Tomcat服务 - >属性 - >登录 - >此帐户 - >从有权访问该用户的用户输入名称/密码通过网络打印机(也许你:))。
Hope it helps, even if the question is some month ago. 希望它有所帮助,即使问题是在一个月前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.