java ee - Unsatisfied dependencies for type [AbstractFacade<Object>] with qualifiers [@Default] at injection point [[BackedAnnotatedField] on GlassFish 4.0 -
when jsf managed bean extends abstract controller, unsatisfied dependencies exception. have methods in abstractcontroller override in policecaselist bean. however, exception below: tried reading here , here , situation seems different.
exception
javax.servlet.servletexception: weld-001408 unsatisfied dependencies type [abstractfacade] qualifiers [@default] @ injection point [[backedannotatedfield] @inject private ijmiscrudgen.backing.abstractcontroller.ejbfacade]
root cause
org.jboss.weld.exceptions.illegalargumentexception: weld-001408 unsatisfied dependencies type [abstractfacade] qualifiers [@default] @ injection point [[backedannotatedfield] @inject private ijmiscrudgen.backing.abstractcontroller.ejbfacade]
@managedbean @viewscoped public class policecaselist extends abstractcontroller<tblcase>{ @inject private tblcasefacade casefacade; private tblcaseperson selectedperson; private tblcase selected; @managedproperty(value = "#{logincontroller}") private logincontroller logincontroller; /** * creates new instance of policecaselist */ public policecaselist() { }
here abstract controller. controller has methods want override. beans annotation @named extend controller , there no complaints ones annotated @managedbean exception above. how can extend abstractcontroller in jsf managed beans without unsatisfied dependency complaints?
public abstract class abstractcontroller<t> { @inject private abstractfacade<t> ejbfacade; private class<t> itemclass; private t selected; private collection<t> items; private boolean trueorfalse; private static int idofsubmittedrecord; private enum persistaction { create, delete, update } public abstractcontroller() { }
the problem mixing two different dependency injection mechanisms: cdi , jsf managed beans/properties. why @named
beans work: cdi annotation, follows cdi rules injection parent classes. on contrary, @managedbean
s live in separate di container, of jsf, , not care cdi annotations.
these 2 worlds communicate through @named
annotation. so, make cdi , use @named
beans through el, if normal jsf managed beans. problem cdi not support view scope of jsf. can solved using e.g. deltaspike jsf module.
bottom line: make cdi. use @named
instead of @managedbean
, @inject
instead of @managedproperty
, deltaspike jsf module things @viewscoped
not provided out-of-the-box cdi.
some references
Comments
Post a Comment