Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ServiceUIFactory  RSS feed

 
Malcolm Storey
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServiceUIFactory always returns null for MAIN_UIROLE



The code prints "null" 4 times.
ServiceFactory prints as: sun.print.Win32PrintService$Win32ServiceUIFactory@13920c99

(I know this duplicates a previous query but nobody answered!)

 
Ante Adamovic
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Malcolm Storey wrote:

(I know this duplicates a previous query but nobody answered!)


That's probably because you didn't provide enough information, it's impossible to know what's wrong with it without seeing where you get your data.


The only thing I can think of is that returns null or that no objects inside it are initialized...(that would explain why it prints 4x "null" values)
 
Malcolm Storey
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ante, but if lookupDefaultPrintService returned null, there'd be a stack trace from the second line.

It could well be that something requires initializing: any suggestions what?
 
Ante Adamovic
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


After checking javadoc it states that it returns null in case that role/type isn't available in your factory,
maybe you could use to obtain all the types available for
the role you need (ServiceUIFactory.MAIN_UIROLE in your example). If it returns an empty array then
that means there's no types available / they're not initialized and that is why you're always getting null
when you try to access those types.

On the topic how to initialize them I have no comment, ServiceUIFactory has no constructor and no
'set' methods.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!