tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Polak <ivan.po...@f4s.sk>
Subject Re: problem with filters on Tomcat 7.0.16 and above
Date Sun, 26 Aug 2012 18:44:02 GMT
Hi,

I have version 4.0.5 of UrlRewriteFilter, I built it from source code
from svn repository (jar file created by maven build script and
included to project). With version 4.0.3 is also the same problem (jar
file downloaded from UrlRewrite home page).

I have all rules for UrlRewriteFilter defined in urlrewrite.xml config
file (which is in WEB-INF directory) and all rules are loaded
succesfully during Tomcat server start (there were confirmation
messages in log file).

When I started Tomcat server,and then in web browser I show first
page-welcome page, doFilter method in UrlRewriteFitlter class is
called (I have a breakpoint on the first line of this method).

all defined rules for UrlRewriteFilter have the same problem.

and now, my Tomcat debug:

first, I have breakpoint on the first line in method:

public ApplicationFilterChain createFilterChain(ServletRequest
request, Wrapper wrapper, Servlet servlet) in
ApplicationFilterFactory.class,

and when I click in web browser on link
http://localhost:8080/app/invitations/ (or other link, which is served
by UrlRewrite filter, this method was not called, why ?

and when I click in web browser on link
http://localhost:8080/app/user/settings.html, which is 'direct' link
to Spring MVC controller, createFilterChain method was called.

thanks

Ivan

Dne 26.8.2012 17:00 "Konstantin Kolinko" <knst.kolinko@gmail.com> napsal(a):
>
> 2012/8/26 Ivan Polak <ivan.polak@f4s.sk>:
> > thank you for your answer.
> >
> > "invitations" is served by a filter and translated from
> > http://localhost:8080/app/invitations/ to Spring MVC controller, in
> > urlrewrite filter configuration is:
> >
> > <rule>
> >         <note></note>
> >         <from>/invitations/(.*)</from>
> >         <to>/invitations.html</to>
> >     </rule>
> >
> > and in Spring MVC configuration is:
> >
> > <bean id="urlMapping"
> >                 class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
> > <property name="mappings">
> >                         <props>
> >                                 <prop key="/invitations.html">invitationsController</prop>
> > ......
> >
> > after Iset logEffectiveWebXml="true" on <Context> in META-INF in my
> > application, I have this messages in log file:
> >
> > ......
> > INFO: web.xml:
> > <?xml version="1.0" encoding="UTF-8"?>
> > <web-app xmlns="http://java.sun.com/xml/ns/javaee"
> >          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
> >          version="3.0"
> >          metadata-complete="true">
> >
> >   <display-name>app</display-name>
> >   <context-param>
> >     <param-name>contextConfigLocation</param-name>
> >     <param-valuee>/WEB-INF/applicationContext.xml
> >             /WEB-INF/applicationContext-services.xml
> >             /WEB-INF/applicationContext-resources.xml
> >             /WEB-INF/applicationContext-mail.xml
> >             /WEB-INF/applicationContext-business.xml
> >             /WEB-INF/applicationContext-security.xml
> >             /WEB-INF/applicationContext-quartz.xml</param-valuee>
> >   </context-param>
> >
> >   <filter>
> >     <filter-name>UrlRewriteFilter</filter-name>
> >     <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
> >     <async-supported>false</async-supported>
> >   </filter>
> >   <filter>
> >     <filter-name>encodingFilter</filter-name>
> >     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
> >     <async-supported>false</async-supported>
> >     <init-param>
> >       <param-name>encoding</param-name>
> >       <param-value>UTF-8</param-value>
> >     </init-param>
> >     <init-param>
> >       <param-name>forceEncoding</param-name>
> >       <param-value>true</param-value>
> >     </init-param>
> >   </filter>
> >   <filter>
> >     <filter-name>messageFilter</filter-name>
> >     <filter-class>org.skynetframework.core.filter.MessageFilter</filter-class>
> >     <async-supported>false</async-supported>
> >   </filter>
> >
> >   <filter-mapping>
> >     <filter-name>UrlRewriteFilter</filter-name>
> >     <url-pattern>/*</url-pattern>
> >     <dispatcher>FORWARD</dispatcher>
> >     <dispatcher>REQUEST</dispatcher>
> >   </filter-mapping>
> >   <filter-mapping>
> >     <filter-name>encodingFilter</filter-name>
> >     <url-pattern>/*</url-pattern>
> >   </filter-mapping>
> >   <filter-mapping>
> >     <filter-name>messageFilter</filter-name>
> >     <url-pattern>/*</url-pattern>
> >     <dispatcher>FORWARD</dispatcher>
> >     <dispatcher>REQUEST</dispatcher>
> >   </filter-mapping>
> >
> >   <servlet>
> >     <servlet-name>jsp</servlet-name>
> >     <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
> >     <init-param>
> >       <param-name>fork</param-name>
> >       <param-value>false</param-value>
> >     </init-param>
> >     <init-param>
> >       <param-name>xpoweredBy</param-name>
> >       <param-value>false</param-value>
> >     </init-param>
> >     <load-on-startup>3</load-on-startup>
> >   </servlet>
> >   <servlet>
> >     <servlet-name>default</servlet-name>
> >     <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
> >     <init-param>
> >       <param-name>debug</param-name>
> >       <param-value>0</param-value>
> >     </init-param>
> >     <init-param>
> >       <param-name>listings</param-name>
> >       <param-value>false</param-value>
> >     </init-param>
> >     <load-on-startup>1</load-on-startup>
> >   </servlet>
> >   <servlet>
> >     <servlet-name>apps</servlet-name>
> >     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
> >     <init-param>
> >       <param-name>contextConfigLocation</param-name>
> >       <param-value>/WEB-INF/app-servlet.xml</param-value>
> >     </init-param>
> >     <load-on-startup>1</load-on-startup>
> >   </servlet>
> >   <servlet>
> >     <servlet-name>pluploadServlet</servlet-name>
> >     <servlet-class>info.app.servlet.servlets.upload.PluploadServlet</servlet-class>
> >   </servlet>
> >
> >   <servlet-mapping>
> >     <servlet-name>jsp</servlet-name>
> >     <url-pattern>*.jsp</url-pattern>
> >   </servlet-mapping>
> >   <servlet-mapping>
> >     <servlet-name>default</servlet-name>
> >     <url-pattern>*.gif</url-pattern>
> >   </servlet-mapping>
> >   <servlet-mapping>
> >     <servlet-name>default</servlet-name>
> >     <url-pattern>*.jpg</url-pattern>
> >   </servlet-mapping>
> >   <servlet-mapping>
> >     <servlet-name>apps</servlet-name>
> >     <url-pattern>*.html</url-pattern>
> >   </servlet-mapping>
> >   <servlet-mapping>
> >     <servlet-name>default</servlet-name>
> >     <url-pattern>*.png</url-pattern>
> >   </servlet-mapping>
> >   <servlet-mapping>
> >     <servlet-name>jsp</servlet-name>
> >     <url-pattern>*.jspx</url-pattern>
> >   </servlet-mapping>
> >   <servlet-mapping>
> >     <servlet-name>default</servlet-name>
> >     <url-pattern>*.css</url-pattern>
> >   </servlet-mapping>
> >   <servlet-mapping>
> >     <servlet-name>default</servlet-name>
> >     <url-pattern>*.js</url-pattern>
> >   </servlet-mapping>
> >   <servlet-mapping>
> >     <servlet-name>pluploadServlet</servlet-name>
> >     <url-pattern>/upload</url-pattern>
> >   </servlet-mapping>
> >
> >   <session-config>
> >     <session-timeout>30</session-timeout>
> >     <cookie-config>
> >     </cookie-config>
> >   </session-config>
> >
> >   <mime-mapping>
> > .....
> >
> >
> > thanks
> >
> > Ivan
> >
> > On 25 August 2012 16:34, Konstantin Kolinko <knst.kolinko@gmail.com> wrote:
> >> 2012/8/25 Ivan Polak <ivan.polak@f4s.sk>:
> >>> Hi!
> >>>
> >>> Recently, we have migrated my web app from Tomcat 6.0.16 to Tomcat
> >>> 7.0.29. The application works fine for most of the part but gives
> >>> problem with URLRewriteFilter. I am using URLRewriteFilter version
> >>> 4.0.5.
>
> The latest released version is 4.0.3.
>
>
> >>>
> >>> In tomcat 6.0.16 everything is OK,
> >>>
> >>> URLRewriteFilter has status information page on
> >>> http://localhost:8080/app/rewrite-status/, with Tomcat 6.0.16 is OK,
> >>> but in tomcat 7.0.16 and above, this page show HTTP Status 404 tomcat
> >>> error screen.
> >>>
> >>> I use tomcat in eclipse, with debug mode (URLRewriteFilter parameter
> >>> logLevel=DEBUG), in console there all messages (the same messages as
> >>> with tomcat 6.0.16), so the filter is started correctly.
> >>>
> >>>     INFO: org.tuckey.web.filters.urlrewrite.Conf DEBUG: about to parse
> >>> conf 24.8.2012 20:09:56 org.apache.catalina.core.ApplicationContext
> >>> log
> >>>     INFO: org.tuckey.web.filters.urlrewrite.ConfHandler
> >>>     DEBUG: Resolving to DTD
> >>> /org/tuckey/web/filters/urlrewrite/dtds/urlrewrite4.0.dtd 24.8.2012
> >>> 20:09:56 org.apache.catalina.core.ApplicationContext log
> >>>     INFO: org.tuckey.web.filters.urlrewrite.Conf DEBUG: now
> >>> initialising conf 24.8.2012 20:09:56
> >>> org.apache.catalina.core.ApplicationContext log
> >>>     INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: loaded
> >>> rule Rule 0 (/test/status/, %{context-path}/rewrite-status 0)
>
> Is the above rule in your rules file?
> (Noting that you do not specify the rule file location, so
> UrlRewriteFilter uses default location).
>
> Are other rules loaded successfully?
> Looking at UrlRewriteFilter code, it does some validation once all the
> rules are loaded.
> Does it succeed?
>
> >>>
> >>> with Tomcat 7.0.16 and above there are problem with defined filters in web.xml.
> >>>
> >>> <filter>
> >>>                 <filter-name>UrlRewriteFilter</filter-name>
> >>>                 <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
> >>> </filter>
> >>>
> >>>         <filter-mapping>
> >>>                 <filter-name>UrlRewriteFilter</filter-name>
> >>>                 <url-pattern>/*</url-pattern>
> >>>                 <dispatcher>REQUEST</dispatcher>
> >>>                 <dispatcher>FORWARD</dispatcher>
> >>>         </filter-mapping>
> >>>
> >>> in Tomcat 7.0.10, 7.0.11, 7.0.12, 7.0.14 is everything OK,
> >>>
> >>> but in Tomcat 7.0.16 and above, method:
> >>>
> >>> public void doFilter(final ServletRequest request, final
> >>> ServletResponse response, final FilterChain chain)
> >>>             throws IOException, ServletException {
> >>>
> >>> in filter is called on welcome-screen
> >>> (http://localhost:8080/app/index.html), but when I click on link
> >>> http://localhost:8080/app/invitations/, method doFilter is not called.
> >>>
> >>> the same situation is with others filters defined in web.xml.
> >>>
> >>
> >> 1. Is "invitations" a subdirectory in your application? (Is Tomcat
> >> looking for a welcome file there?) Or it is served by a servlet, or by
> >> a filter?
> >>
> >> 2. Can you reproduce this with the standard "examples" webapp?
> >>
> >> 3. Try to dump "merged web.xml": set logEffectiveWebXml="true" on <Context>
> >> and look for filter and filter-mapping elements there. What is their order?
> >> http://tomcat.apache.org/tomcat-7.0-doc/config/context.html
> >>
>
> Can you run with a debugger?
> http://wiki.apache.org/tomcat/FAQ/Developing#Debugging
>
> E.g. with a breakpoint in UrlRewriteFilter.
>
> On Tomcat side, the method that builds the chain of filter for a request is
> org.apache.catalina.core.ApplicationFilterFactory#createFilterChain(..)
>
> The dumped configuration looks OK and I do not see how a filter can be omitted.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message