3 Replies Latest reply on May 23, 2017 1:35 PM by meganrupert

    JBoss EAP7 skips servlet filters in web.xml

    pranav.cache

      We are migrating an old application. We had to use Jdeveloper and Jboss server.

      We have build the application on JDeveloper 12c and then created a war file by creating a profile. Later we deployed this war file in JBoss EAP 7.0.0 server (copied the war and pasted in D:\jboss-eap-7.0.0\standalone\deployments) and started the standalone. The application is coming up but its not executing the filters we have mentioned in the web.xml file. I have written a SysOut statement in doFilter , which is not showing up.

      If we run the applicatioin Jdeveloper itself its running fine in the default weblogic server.

      Are we missing something? Below is the web.xml file.

      <?xml version = '1.0' encoding = 'windows-1252'?>

      <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

      <web-app>

          <description>Empty web.xml file for Web Application</description>

          <context-param>

              <param-name>authority</param-name>

              <param-value>https://login.windows.net/</param-value>

          </context-param>

          <context-param>

              <param-name>tenant</param-name>

              <param-value>TENANT</param-value>

          </context-param>

         <filter>

                 <filter-name>BasicFilter</filter-name>

                 <filter-class>com.org.aad.BasicFilter</filter-class>

                 <init-param>

                     <param-name>client_id</param-name>

                     <param-value>CLIENT_ID</param-value>

                 </init-param>

                 <init-param>

                     <param-name>secret_key</param-name>

                     <param-value>SECRET_KEY</param-value>

                 </init-param>

             </filter>

             <filter-mapping>

                 <filter-name>BasicFilter</filter-name>

                 <url-pattern>/controller/*</url-pattern>

          </filter-mapping>

          <welcome-file-list>

              <welcome-file>logon.jsp</welcome-file>

          </welcome-file-list>

          <servlet-mapping>

              <url-pattern>/controller</url-pattern>

              <servlet-name>ControlServlet</servlet-name>

          </servlet-mapping>

       

          <servlet>

              <servlet-name>ControlServlet</servlet-name>

              <servlet-class>com.org.ControlServlet</servlet-class>

          </servlet>

        

          <session-config>

              <session-timeout>90</session-timeout>

          </session-config>

          <mime-mapping>

              <extension>html</extension>

              <mime-type>text/html</mime-type>

          </mime-mapping>

          <mime-mapping>

              <extension>txt</extension>

              <mime-type>text/plain</mime-type>

          </mime-mapping>

      </web-app>

        • 1. Re: JBoss EAP7 skips servlet filters in web.xml
          ranjith_pulluru

          Please provide the url you are accessing to run the servlet filter and also paste the content of the `com.org.aad.BasicFilter` you are using.

          • 2. Re: JBoss EAP7 skips servlet filters in web.xml
            sendi_t34

            I have same problem, I have deployed my application on openshift jboss EWS 7.. and I can see my new filter classes in web_inf dir on server.. but the servlet filter does not intercept requests

             

             

            public class AuthenticationFilter implements Filter {

                private final static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger("AuthenticationFilter");

                private static final String LOG_IN_PAGE = "login.jsp";

                private static final String CLIENT_VIEW_PAGE = "ClientView.jsp";

             

                @Override

                public void init(FilterConfig filterConfig) throws ServletException {

                    //noop

                }

             

                @Override

                public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

                    //session already active in JSP

                    HttpServletRequest req = (HttpServletRequest) request;

                    HttpServletResponse resp = (HttpServletResponse) response;

                    HttpSession session = req.getSession(false);

                    boolean pageAllowedWithoutEntitlements = isPageAllowedWithoutEntitlements(req);

             

                    boolean loggedIn = (session != null) && (session.getAttribute("app_user") != null);

             

                    try {

                        if (loggedIn || pageAllowedWithoutEntitlements || req.getRequestURI().matches(".*(css|ico|jpg|png|gif|svg|js|otf|eot|ttf|woff|woff2)$")) {

                              chain.doFilter(request, response);

            else {

                            LOG.warn("Page requested but user not logged in , redirecting to login page: " + req.getRequestURI());

                            String REDIRECT_URL = LOG_IN_PAGE;
                                resp.sendRedirect(resp.encodeRedirectURL(REDIRECT_URL));
            }

            }
            }

            @Overrid
            public void destroy() {
                //noop
            }

             

            /***********************webxml ****************************************/

             

               <filter>

                    <filter-name>LoggingFilter</filter-name>

                    <filter-class>com.app.filters.AuthenticationFilter</filter-class>

                </filter>

                <filter-mapping>

                    <filter-name>LoggingFilter</filter-name>

                    <url-pattern>/*</url-pattern>

                </filter-mapping>

            • 3. Re: JBoss EAP7 skips servlet filters in web.xml
              meganrupert

              We had the same problem when we moved to EAP7.

               

              To fix we added another filter mapping without the wildcard:

               

                <filter-mapping>

                         <filter-name>BasicFilter</filter-name>

                         <url-pattern>/controller/*</url-pattern>

                 </filter-mapping>

                <filter-mapping>

                         <filter-name>BasicFilter</filter-name>

                         <url-pattern>/controller/</url-pattern>

                 </filter-mapping>

               

              No idea why it's working now, but it is