0

i have a @Singleton Bean that i want to use in another @stateless Bean, is that correct or doable? and can i reference the stateless bean using @EJB? in this thread i read that i can't. should i use only lookup? why?

thanks.

Community
  • 1
  • 1
solaechea
  • 89
  • 11

1 Answers1

0

That answer is talking about injecting a @Stateful in a @Stateless which is indeed an extremely bad idea. But you've there just a @Singleton and you should be able to inject it without any trouble in any kind of EJB (as long as it is really been designed as such that it indeed deserves a @Singleton), there's only one unique instance of the @Singleton anyway.

See also this related answer: access existing instance stateful inside stateless, java ee 6.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555