java - Inconsistent Results from javax.print library -


i have section of code within web app, running in tomcat 5.0, makes call javax.print.printservicelookup method lookupprintservices(null, null). previously, code returned array of substantial size, listing printers on server expected. rather 1 day recently, started behaving differently, returning a zero-size array of no printers instead. checking rather thoroughly, not able determine might have changed cause method behave differently did before.

i made small, stand-alone test program contained same method call.

    printservice[] printers = printservicelookup.lookupprintservices(null, null);      system.out.println("java version: " + system.getproperty("java.version"));     system.out.println("printers found:");     if (printers != null) {         (printservice printer : printers) {             if (printer != null) {                 system.out.println("    " + printer.tostring());             }         }     }     system.out.println("end"); 

running program, reacted differently, returning full list of printers. double-checking, put same code (using logging statements instead of system.print statements) in context initialization method of web app, , still returns zero printers. method returns different results depending on whether run web app war or stand-alone jar.

some of colleagues suggested might have security manager, , indeed, documentation printservice class says properties of security manager can alter results method call. however, after adding code test retrieve , view security manager, appears there none in either case.

    try {         if (sec != null) {             system.out.println(sec.tostring());             sec.checkprintjobaccess();         }         system.out.println("*-*-*-*-*printer access allowed!!");     }     catch (securityexception e) {         system.out.println("*-*-*-*-*printer not access allowed!!");     } 

the result security manager null in both cases.

trying on different server, both web app , stand-alone jar versions of doing things return no printers. there no consistency can find.

what going on here? causing javax method call return different results in different situations? have changed web app alter behavior between 1 day , next?

try starting server option -dusesunhttphandler=true initiate http url connection jdk api instead of server api. hope works too.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -