Weblogic 10.3.0, Struts, Alfresco, Sitemesh and Tuckey’s URLRewritingFilter

Post date: May 29, 2012 2:31:52 PM

Powerful, but also tricky to get it working on Weblogic. I want to thank all that posted their questions and struggles with this combination on the different Sitemesh and Tuckey’s URLRewriteFilter related forums. However, I was puzzled that initially the application ran on Tomcat smoothly, but not on Weblogic.

No concrete explanations for Weblogic were found anywhere. What happened on my side was that the decorator was simply lost, no other meaningful error was encountered.

Therefore I wanted to write down the “golden rules” for making it running on Weblogic 10.3:

· Follow the <filter-mapping> order inside web.xml exactly as described here.

· Consider the REQUEST dispatcher for URLRewriteFilter.

· Consider the INCLUDE and FORWARD dispatchers for SitemeshFilter.

web.xml:

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4"

xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>CP</display-name>

<!-- Quartz Listener for initialization -->

<listener>

<listener-class>org.quartz.ee.servlet.QuartzInitializerListener</listener-class>

</listener>

<context-param>

<description>The logos path in consular_protection alfresco web project</description>

<param-name>logos.folder.path</param-name>

<param-value>/consular_protection/logos</param-value>

</context-param>

<listener>

<description>Configure Listener</description>

<listener-class>eu.ec.jls.cp.listener.ConfigureListener</listener-class>

</listener>

<!-- FILTERS -->

<filter>

<filter-name>CharacterEncodingFilter</filter-name>

<filter-class>eu.ec.jls.cp.web.CharacterEncodingFilter</filter-class>

</filter>

<filter>

<filter-name>struts-cleanup</filter-name>

<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>

</filter>

<filter>

<filter-name>sitemesh</filter-name>

<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>

</filter>

<filter>

<filter-name>struts</filter-name>

<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>

</filter>

<filter>

<filter-name>UrlRewriteFilter</filter-name>

<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>

<init-param>

<param-name>confReloadCheckInterval</param-name>

<param-value>-1</param-value>

</init-param>

<init-param>

<param-name>logLevel</param-name>

<param-value>DEBUG</param-value>

</init-param>

</filter>

<filter-mapping>

<filter-name>struts-cleanup</filter-name>

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

<dispatcher>FORWARD</dispatcher>

<dispatcher>REQUEST</dispatcher>

</filter-mapping>

<filter-mapping>

<filter-name>sitemesh</filter-name>

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

<dispatcher>INCLUDE</dispatcher>

<dispatcher>FORWARD</dispatcher>

</filter-mapping>

<filter-mapping>

<filter-name>UrlRewriteFilter</filter-name>

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

<dispatcher>REQUEST</dispatcher>

</filter-mapping>

<filter-mapping>

<filter-name>CharacterEncodingFilter</filter-name>

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

<dispatcher>FORWARD</dispatcher>

<dispatcher>REQUEST</dispatcher>

</filter-mapping>

<filter-mapping>

<filter-name>struts</filter-name>

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

<dispatcher>FORWARD</dispatcher>

<dispatcher>REQUEST</dispatcher>

</filter-mapping>

<servlet>

<servlet-name>jspSupportServlet</servlet-name>

<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet>

<servlet-name>jcaptcha</servlet-name>

<servlet-class>eu.ec.jls.cp.web.ImageCaptchaServlet</servlet-class>

<load-on-startup>0</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>jcaptcha</servlet-name>

<url-pattern>/jcaptcha.jpg</url-pattern>

</servlet-mapping>

<!-- Welcome file lists -->

<welcome-file-list>

<welcome-file>welcome.html</welcome-file>

</welcome-file-list>

<mime-mapping>

<extension>ico</extension>

<mime-type>image/x-icon</mime-type>

</mime-mapping>

</web-app>