PrintServiceLookup.lookupPrintService solution in JBoss AS 7

前提是你 提交于 2019-12-22 10:28:48

问题


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:


  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.



来源:https://stackoverflow.com/questions/16666786/printservicelookup-lookupprintservice-solution-in-jboss-as-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!