CDI in a servlet produces NullPointerException -
i trying use cdi in servlet, here snippet of servlet code
public class myservlet extends httpservlet{ @inject @any instance<myprocedure> procedures; public void handlerequest(servletrequest req, servletresponse res) throws exception { if (procedures == null) { system.out.println("procedure list null"); } (object o : procedures) { system.out.println("calling procedure " + o.tostring()); } } }
myprocedure interface , appliation war contains couple of classes implement myprocedure.
i nullpointerexception because list of procedures null...i have beans.xml file in web-inf directory.
i found out problem was. interface implemented beans had included in war archive under web-inf/lib. after did started work expected.
Comments
Post a Comment