6 Replies Latest reply on Aug 25, 2014 8:08 PM by jamezp

    Why is wildfly eating my stdios?

    tchize

      Hello,

       

      after struggling to find out why JSF threw me an empty page without a single error message during a migration, I found out that, when I'm in the context of a ServletFilter (and only at that time AFAIK), any attempt to write to stdout or stderr ends up in jboss Class StdioContext to send this text to a NullOutputStream.

       

      so,

       

      why is wildfly disabling stdout / stderr during that request phase?

      How can I tell it not to do so?

       

      The servletfilter is the moment i handle some exceptions, clean up datas, and spur out a small message in console telling something uncommon happened to the application. Note that this also affect my log calls because my handler is a console handler!

       

       

      This obviously affect any log attempt, any System.out/System.err print attempt and any call to exception.printStackTrace(). This currently means my servletFilter has no way to communicate events to the administrator :/

       

      I tested same code in a JSF bean, in a JSP scriptlet, it has access to output. Only during filter is there no access. Like if JBoss had an additionnal filter that sets up STDIO, but this filter is only called after my filters!

        • 1. Re: Why is wildfly eating my stdios?
          ctomc
          • 2. Re: Why is wildfly eating my stdios?
            tchize

            I don't see how that message relates to my question. This other thread mention why Main in a standalone console application replaces System.in, which obviously is a bug. Here i'd like to know what are the rules in wildfly relating to stdout/stderr during normal webapplication lifecycle and how to configure it, more specifically  in the case of servlet filter.

            • 3. Re: Why is wildfly eating my stdios?
              jamezp

              You shouldn't be getting a NullOutputStream from STDIO. There is a DelegatingPrintStream that extends PrintStream and initializes the super class with a NullOutputStream, but all methods should be overridden. Nothing should be executing on the NullOutputStream.

               

              The stdout should be going to a logger with the category "stdout" and stderr should be going to a logger with the category "stderr".

               

              --
              James R. Perkins

              • 4. Re: Why is wildfly eating my stdios?
                tchize

                I agree I shouldn't, but it is a fact that is what I get it. During servlet / jsp / inside JSB beans everything is properly redirected to stdout logger. But during servlet filter, it's not the case. It's neither the case before calling rest of the filter chain, nor after calling it. Where should I start investigations to find out what causes it?

                • 5. Re: Why is wildfly eating my stdios?
                  jaikiran

                  I think it's fair to expect the System.out and System.err logs from any component within a web application to be seen on the console (or wherever they are redirected to). If that isn't happening then, IMO, that's a bug. You can create a JIRA here WildFly - JBoss Issue Tracker explaining the problem and pointing to this discussion. If possible attach a sample application which reproduces this.

                  • 6. Re: Re: Why is wildfly eating my stdios?
                    jamezp

                    I just tested a very simple filter on WidFly 8.1.0.Final and it worked fine for me.

                     

                    package org.jboss.example.servlet;
                    
                    
                    import java.io.IOException;
                    import javax.servlet.Filter;
                    import javax.servlet.FilterChain;
                    import javax.servlet.FilterConfig;
                    import javax.servlet.ServletException;
                    import javax.servlet.ServletRequest;
                    import javax.servlet.ServletResponse;
                    import javax.servlet.annotation.WebFilter;
                    
                    
                    /**
                     * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
                     */
                    @WebFilter(filterName = "TestFilter", urlPatterns = "/*")
                    public class TestFilter implements Filter {
                        public void destroy() {
                            System.out.println("From destroy");
                        }
                    
                    
                        public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
                            chain.doFilter(req, resp);
                            System.out.println("From doFilter");
                        }
                    
                    
                        public void init(FilterConfig config) throws ServletException {
                            System.out.println("From init");
                        }
                    
                    
                    }
                    

                     

                    I saw all the messages printed on the console:

                    17:04:16,154 INFO  [stdout] (default task-1) From init
                    17:04:16,162 INFO  [stdout] (default task-1) From doFilter
                    17:04:27,495 INFO  [simple] (default task-3) This is just a test
                    

                     

                     

                    --

                    James R. Perkins