Monday 15 September 2014

Manually called Servlet-Filter - injected EJB always null (NullPointerException) -


I have a problem with ServletFiltering and EJB injection. I have configured a ServletFilter and have included it to my web.xml

Filter-orbit:.

  package at.dot.web.rest.common.utils; Public class AuthRequestFilter filter {@EJB Private RequestValidator RV Applies; @Override public void doFilter (ServletRequest servletRequest, ServletResponse ServletResponse, FilterChain filterChain) IOException, ServletException {AuthRequestWrapper wr = new AuthRequestWrapper ((HttpServletRequest) servletRequest) throws; If (rv.isRequestAccepted (WR)) {filterChain.doFilter (wr, ServletResponse); } @ Override Public Wide Init (Filtrconfig filter config) has Srvislet Akspesheshn removed {@} override public Boyd Dist () {}}   

web.xml:

  & lt; Filter & gt; & Lt; Filter-name & gt; AuthRequestFilter & lt; / Filter-name & gt; & Lt; Filter range & gt; At.dot.web.rest.common.utils.AuthRequestFilter & lt; / Filter range & gt; & Lt; / Filter & gt; & Lt; Filter-mapping & gt; & Lt; Filter-name & gt; AuthRequestFilter & lt; / Filter-name & gt; & Lt; URL pattern & gt; / * & Lt; / URL pattern & gt; & Lt; / Filter-mapping & gt;   

Ever looks good and works without problems. I now the whole thing was to make a little more flexible and came to this article: I was GodFilter including as suggested in answere that FilterChain and patterns. Very well working Thats Filter is defined as what is my problem: EJB (RV) is not injection. It is always a weakness for me. I am pretty sure that I am remembering any (ordinary) issue - but still I did not get the fault.

Any thoughts?

Thank you

So I fixed the problem by themselves:

  apply scanned Sthirhin @ @ @ Local Revest public square AuthRequestFilter filter {..} @RequestScoped public class Mastrfiltr filter applied {@EJB (beanName = "AuthRequestFilter") private AuthRequestFilter arf; ..}   

Of course it does not inject new AuthRequestFilter () Ijebi - I have to inject filters.

No comments:

Post a Comment