Dependency Injection Sucks

Java EE platform has many benefits one of them is Dependency Injection. It is an useful feature provides just using annotations instead of making lookups. However you cannot use it anywhere you like, only container managed components accepts resource injection. Such as EJB beans, Servlets, and JavaServer Pages (JSP) technology tag handlers. Thus, you can not use it in your helper classes and JPS pages. Why you cannot use it is;

JSP technology pages and tag files cannot accept resource injections either. Because such pages are usually compiled only after receiving a request, an annotation included in a JSP technology page would not be available to the container at deployment time when resource injection occurs.

Tag library validators (TLVs) and TagExtraInfo (TEI) are other classes that the JSP technology container manages, but because their life cycle is limited to the compilation of the JSP technology pages, they are not valid candidates for injection.

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.

You cannot use this nice feature where it is most useful, it really sucks.

Ref : A Look at Resource Injection