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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -