PrintServiceLookup.lookupPrintServices()
You can also get the default printer connected to the server by using the code:
PrintServiceLookup.lookupDefaultPrintService()
When I use the above code in standalone java program, it pulls the printers and I was able to print it, but the same is not working while doing it through Web application. jBoss does not allow the java print services to look up on the printers connected to it. After doing analysis, I found out the following configuration solving the issues
1) Add extra tag in modules/sun/jdk/main/module.xml of jbossAs as mentioned: path name="sun/print"
<dependencies> <system export="true"> <paths> <path name="com/sun/script/javascript"/> <path name="com/sun/jndi/dns"/> <path name="com/sun/jndi/ldap"/> <path name="com/sun/jndi/url"/> <path name="com/sun/jndi/url/dns"/> <path name="com/sun/security/auth"/> <path name="com/sun/security/auth/login"/> <path name="com/sun/security/auth/module"/> <path name="sun/misc"/> <path name="sun/io"/> <path name="sun/nio"/> <path name="sun/nio/ch"/> <path name="sun/security"/> <path name="sun/security/krb5"/> <path name="sun/util"/> <path name="sun/util/calendar"/> <path name="sun/util/locale"/> <path name="sun/security/provider"/> <path name="META-INF/services"/> <!-- Updated for implementing SAML on 22nd June 2015--> <path name="javax/xml/crypto/dsig"/> <path name="javax/xml/crypto"/> <path name="javax/xml/crypto/dsig/dom"/> <path name="javax/xml/crypto/dsig/keyinfo"/> <path name="com/sun/org/apache/xml/internal/security/transforms/implementations"/> <path name="org/jcp/xml/dsig/internal/dom"/> <!-- Updated for adding PrintServices to print the files from jBoss server--> <path name="sun/print"/> </paths> <exports> <include-set> <path name="META-INF/services"/> </include-set> </exports> </system> </dependencies>
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.
No comments:
Post a Comment