i had trouble detecting printers under JBoss in an EJB, but it worked when debugging and runnign under Forte without the EJB container. So i tried it in a servlet to see if the EJB container was really the issue.
this is part of my servlet
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
// see what printers are available.
javax.print.PrintService[] availableServices = javax.print.PrintServiceLookup.lookupPrintServices(null, null);
response.setContentType("text/html");
java.io.PrintWriter out = response.getWriter();
// output your page here
out.println("");
out.println("");
out.println("Servlet");
out.println("");
out.println("");
out.println("availableServices = " + availableServices.length);
out.println("");
out.println("");
//
out.close();
}
this static lookup returns two printers when executed in a regular class, or under Forte, but none when running in an EJB or from a servlet.
i see "availableServices = 0" on the HTML page.
There are no error messages in the JBOSS log, and JAVAHOME is correctly set. It is clear that the javax.print.lookup is executed.
does anyone have any words of wisdom ?
thanks
I solved it. Its running as a service and as the LOCAL SYSTEM account. this has no printers, although my user does.