过滤器在 Glassfish 3.1.1 中不起作用
我有一个 Filter 实现,以前在单个实例 Glassfish 3.1.1 中工作过。
它已使用 @WebFilter 进行注释,如下所示:
@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
}
应在每个请求中调用它。
现在我有一个 Glassfish 设置,它有两个单独的 FRONT 和 SERVICE 实例。我将包含过滤器的 WAR 部署到 FRONT,但过滤器似乎不起作用。我尝试了日志记录和调试,但似乎过滤器或至少 doFilter 方法从未被调用。我还尝试将一些日志记录放入 init 方法中,但它也根本没有显示在日志中。
任何人都知道什么可能会导致这种行为。有没有办法以某种方式记录 Glassfish 过滤链?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否检查 Glassfish server.log 中是否存在有关过滤器初始化的错误?我遇到过类似的问题,并预感到过滤器初始化是导致问题的原因。
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.