This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes EJB injection doesn't work in JSF Convertor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB injection doesn Watch "EJB injection doesn New topic
Author

EJB injection doesn't work in JSF Convertor

Vladimir Kroupa
Greenhorn

Joined: Dec 26, 2008
Posts: 28
Hi,
I'm using JSF with EJB. In my JSF managed beans, the dependency injection through @EJB annotation works fine. However, in my custom JSF Validator and Convertor classes, the @EJB annotation doesn't work. The annotated variable remains null and throws a NullPointerException later. Is there anything I am missing about dependency injection in EJB? I thought that I can use @EJB annotation in any container managed class (which JSF Validators and Convertors are).

Thanks for any input,
Vladimir
Vladimir Kroupa
Greenhorn

Joined: Dec 26, 2008
Posts: 28
Seems that I was wrong. Resource injection works only in JSF managed beans.
http://java.sun.com/developer/technicalArticles/J2EE/injection/index.html
Supporting resource injection on JavaServer Faces technology renderers, converters, or validators is not desirable because that would violate Model-View-Controller (MVC) separation of these presentation objects. If these classes need to get access to resources, they should do so through a managed bean.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: EJB injection doesn't work in JSF Convertor