问题
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"
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.Restart JBoss and run the application.
来源:https://stackoverflow.com/questions/16666786/printservicelookup-lookupprintservice-solution-in-jboss-as-7