简体   繁体   中英

Filter not working in Glassfish 3.1.1

I have a Filter implementation that has worked previously in a single instance Glassfish 3.1.1.

It has been annotated with @WebFilter and is as follows:

@WebFilter(urlPatterns = { "/*" })
public class SomeFilter implements Filter {

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
        ServletException {
HttpServletRequest req = (HttpServletRequest) request;
...
}

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    // do nothing
}

@Override
public void destroy() {
    // do nothing
}

It should be invoked with every request.

Now I have a Glassfish setup that has two separate instances for FRONT and SERVICE. I deploy the WAR containing the filter to FRONT and the Filter does not seem to work. I tried logging and debugging, but it seems the filter, or at least the doFilter-method is never invoked. I also tried to put some logging to init method but it also isn't showing up on the logs at all.

Anyone know what might cause such behaviour. Is there a way to log the Glassfish filterchain somehow?

Did you check the Glassfish server.log for errors regarding initialization of the filter? I've encountered similar problems and got a hunch that filter initialization is the cause of your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM