JBoss AS 7中的PrintServiceLookup.lookupPrintService解决方案 [英] PrintServiceLookup.lookupPrintService solution in JBoss AS 7

查看:431
本文介绍了JBoss AS 7中的PrintServiceLookup.lookupPrintService解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的JSF Web应用程序中打印pdf文档。



当我从main方法调用方法 findPrinter()时, PrintServices ,但是当我从网页上调用此方法找不到PrintService 时。下面提到的代码..

  public static void main(final String [] args)抛出异常{
PrintTest printTest = new PrintTest();
printTest.findPrinter();
}

public void findPrinter(){

PrintService [] printServices = PrinterJob.lookupPrintServices();
System.out.println(Print Services Length ::+ printServices.length);
for(PrintService printService:printServices){
System.out.println(PrintService ::+ printService);
}

< h:form>
< p:commandButton value =Printaction =#{printTest.findPrinter()}/>
< / h:form>

任何建议......

如下所述:
路径名= sun / print


  • 从您的JRE打开resources.jar,并提取

    META-INF / services / javax.print.PrintServiceLookup并复制到位置
    modules / sun / jdk / main / service-loader-resources / META-INF / JbossAS服务。


  • 重新启动JBoss并运行该应用程序。



  • I am trying to print a pdf document from my JSF web application.

    When I call the method findPrinter() from main method, PrintServices are found, but when I call this method from web page PrintService are not found. Code mentioned below..

     public static void main(final String[] args) throws Exception {
        PrintTest printTest = new PrintTest();
        printTest.findPrinter();
     }
    
     public void findPrinter() {
    
        PrintService[] printServices = PrinterJob.lookupPrintServices();
        System.out.println("Print Services Length :: " + printServices.length);
        for (PrintService printService : printServices) {
            System.out.println("PrintService :: " + printService);
    }
    
       <h:form>
        <p:commandButton value="Print" action="#{printTest.findPrinter()}"/> 
       </h:form>
    

    Any suggestions...

    解决方案

    1. Add extra tag in modules/sun/jdk/main/module.xml of jbossAs as mentioned: path name="sun/print"

    2. Open up resources.jar from your JRE, and extract
      META-INF/services/javax.print.PrintServiceLookup and copy to location modules/sun/jdk/main/service-loader-resources/META-INF/services of JbossAS.

    3. Restart JBoss and run the application.

    这篇关于JBoss AS 7中的PrintServiceLookup.lookupPrintService解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆