简体   繁体   English

当我使用services.msc启动服务器时,打印在tomcat中不起作用(从客户端我们无法打印)

[英]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.

相关问题 当我从 eclipse 运行 JDialog 时,Swing JDialog 显示正常,但不能从 windows 服务(services.msc)运行 - Swing JDialog is showing fine when I run it from eclipse but not working from windows service(services.msc) 将Jetty服务器作为服务运行在services.msc中并自动启动时需要 - Required to Run Jetty server as a service which should availabe in services.msc and auto started 如果对等客户端与服务器断开连接,我们是否可以忽略服务器端的套接字异常? - If a peer client disconnects from a server could we just ignore the socketexception at the server side? Tomcat 服务器无法启动 - Tomcat server could not start 在java web应用程序中如何从客户端打印服务器文件 - In java web application how to print server file from client side Java中的服务器客户端:无法启动客户端 - Server Client in Java: could not start client 在两台不同的计算机上创建RMI应用程序时,客户端和服务器应在哪里定义接口客户端或服务器端? - When creating an RMI application on two different machines Client and Server Where should we Define our Interface Client side or Server side? 启动应用程序时,MyEclipse Tomcat服务器没有响应 - MyEclipse Tomcat server is not responding when i start my application 如何在客户端修复打印服务器端输出 - How to fix printing server side output in client side 通过打印服务器打印动态生成的服务器端HTML - Printing dynamically generated server-side HTML through Print Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM