Thanks Musachy, those filters seem to work with the regular SiteMeshFilter! I still get the same exception when using the FreeMarkerPageFilter, but the regular com.opensymphony.sitemesh.webapp.SiteMeshFilter works and I am able to access the ValueStack with Freemarker in my decorator without any problem!
For those interested, my final minimal web.xml that allows me to use Freemarker for my Sitemesh decorators looks like this: <code> <web-app id="starter" 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>struts2test</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext*.xml</param-value> </context-param> <!-- Filters --> <filter> <filter-name>struts-prepare</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class> <init-param> <param-name>actionPackages</param-name> <param-value>org.gbif.action</param-value> </init-param> </filter> <filter> <filter-name>struts-execute</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class> </filter> <filter> <filter-name>sitemesh</filter-name> <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class> </filter> <filter-mapping> <filter-name>struts-prepare</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <filter-mapping> <filter-name>struts-execute</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> <!-- Listeners --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- Servlets --> <servlet> <servlet-name>jspSupportServlet</servlet-name> <servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class> <load-on-startup>5</load-on-startup> </servlet> <servlet> <servlet-name>sitemesh-freemarker</servlet-name> <servlet-class>com.opensymphony.module.sitemesh.freemarker.FreemarkerDecoratorServlet</servlet-class> <init-param> <param-name>TemplatePath</param-name> <param-value>/</param-value> </init-param> <init-param> <param-name>default_encoding</param-name> <param-value>UTF-8</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>sitemesh-freemarker</servlet-name> <url-pattern>*.dec</url-pattern> </servlet-mapping> </web-app> </code> One last remark. Looking at the showcase example, there are several outcommented snippets at the end of the web.xml showing how to use velocity or freemarker alternatively. The Freemarker example still uses the old filters like I did together with the FreeMarkerPageFilter. Maybe you should replace this with the ng filters. many thanks again, Markus Musachy Barroso wrote: > > The new ones are: > > <filter> > <filter-name>struts-prepare</filter-name> > > <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class> > </filter> > > <filter> > <filter-name>struts-execute</filter-name> > > <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class> > </filter> > > look at the showcase web.xml for examples. I am not saying it will fix > your problem, but you should start using those in 2.1.6+ > > musachy > > On Fri, Jan 30, 2009 at 5:49 AM, Markus Doring <mdoer...@gbif.org> wrote: >> >> Not sure what the new ones are, but my Maven dependency uses version >> 2.1.6 of >> the struts2 sitemesh plugin: >> <code> >> <dependency> >> <groupId>org.apache.struts</groupId> >> <artifactId>struts2-sitemesh-plugin</artifactId> >> <version>${struts.version}</version> >> </dependency> >> ... >> <struts.version>2.1.6</struts.version> >> </code> >> >> Is there any other filter I can try? >> Markus >> >> >> Musachy Barroso wrote: >>> >>> Did you try with the new filters? >>> >>> musachy >>> >>> On Thu, Jan 29, 2009 at 7:44 PM, Markus Doring <mdoer...@gbif.org> >>> wrote: >>>> >>>> Hi, >>>> I am trying Struts 2.1.6 with Freemarker Sitemesh decorators. I am >>>> getting a >>>> NPE in the PageFilter HeadTag class. When debugging it seems the >>>> getPage() >>>> call in the class returns Null. This only happens for the >>>> decorator:head >>>> and >>>> not for the body or title (If I remove the <@decorator.head/> from my >>>> decorator it works fine). The error is: >>>> >>>> <code> >>>> java.lang.NullPointerException >>>> at >>>> com.opensymphony.module.sitemesh.taglib.decorator.HeadTag.doEndTag(HeadTag.java:33) >>>> at >>>> freemarker.ext.jsp.TagTransformModel$TagWriter.endEvaluation(TagTransformModel.java:431) >>>> at >>>> freemarker.ext.jsp.TagTransformModel$TagWriter.onStart(TagTransformModel.java:370) >>>> at freemarker.core.Environment.visit(Environment.java:295) >>>> at freemarker.core.UnifiedCall.accept(UnifiedCall.java:130) >>>> at freemarker.core.Environment.visit(Environment.java:209) >>>> at freemarker.core.MixedContent.accept(MixedContent.java:92) >>>> at freemarker.core.Environment.visit(Environment.java:209) >>>> at freemarker.core.Environment.process(Environment.java:189) >>>> at freemarker.template.Template.process(Template.java:237) >>>> at >>>> org.apache.struts2.sitemesh.FreeMarkerPageFilter.applyDecorator(FreeMarkerPageFilter.java:160) >>>> at >>>> org.apache.struts2.sitemesh.TemplatePageFilter.applyDecorator(TemplatePageFilter.java:116) >>>> at >>>> com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:62) >>>> </code> >>>> >>>> >>>> I have tried to use the standard SiteMeshFilter instead of the >>>> FreeMarkerPageFilter and then I dont encounter any problem. But of >>>> course >>>> I >>>> can't access the struts value stack anymore, so I need to get the >>>> FreemarkerPageFilter working. Has anyone been successful in this >>>> combination? >>>> >>>> The relevant part of my web.xml looks like this: >>>> <code> >>>> <display-name>struts2test</display-name> >>>> <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.sitemesh.webapp.SiteMeshFilter</filter-class> >>>> <!-- >>>> >>>> <filter-class>org.apache.struts2.sitemesh.FreeMarkerPageFilter</filter-class> >>>> --> >>>> </filter> >>>> <filter> >>>> <filter-name>struts</filter-name> >>>> >>>> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> >>>> <init-param> >>>> <param-name>actionPackages</param-name> >>>> <param-value>com.specieslog.action</param-value> >>>> </init-param> >>>> </filter> >>>> >>>> <filter-mapping> >>>> <filter-name>struts-cleanup</filter-name> >>>> <url-pattern>/*</url-pattern> >>>> <dispatcher>REQUEST</dispatcher> >>>> <dispatcher>FORWARD</dispatcher> >>>> </filter-mapping> >>>> <filter-mapping> >>>> <filter-name>sitemesh</filter-name> >>>> <url-pattern>/*</url-pattern> >>>> <dispatcher>REQUEST</dispatcher> >>>> <dispatcher>FORWARD</dispatcher> >>>> <dispatcher>INCLUDE</dispatcher> >>>> </filter-mapping> >>>> <filter-mapping> >>>> <filter-name>struts</filter-name> >>>> <url-pattern>/*</url-pattern> >>>> <dispatcher>REQUEST</dispatcher> >>>> <dispatcher>FORWARD</dispatcher> >>>> </filter-mapping> >>>> >>>> >>>> <!-- Servlets --> >>>> <servlet> >>>> <servlet-name>jspSupportServlet</servlet-name> >>>> >>>> <servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class> >>>> <load-on-startup>5</load-on-startup> >>>> </servlet> >>>> >>>> <servlet> >>>> <servlet-name>sitemesh-freemarker</servlet-name> >>>> >>>> <servlet-class>com.opensymphony.module.sitemesh.freemarker.FreemarkerDecoratorServlet</servlet-class> >>>> <init-param> >>>> <param-name>TemplatePath</param-name> >>>> <param-value>/</param-value> >>>> </init-param> >>>> <init-param> >>>> <param-name>default_encoding</param-name> >>>> <param-value>UTF-8</param-value> >>>> </init-param> >>>> <load-on-startup>1</load-on-startup> >>>> </servlet> >>>> <servlet-mapping> >>>> <servlet-name>sitemesh-freemarker</servlet-name> >>>> <url-pattern>*.dec</url-pattern> >>>> </servlet-mapping> >>>> </code> >>>> >>>> >>>> My struts.xml is this minimal one, making Freemarker the default result >>>> type: >>>> <code> >>>> <package name="default" namespace="/" extends="struts-default"> >>>> <result-types> >>>> <result-type name="freemarker" >>>> class="org.apache.struts2.views.freemarker.FreemarkerResult" >>>> default="true"/> >>>> </result-types> >>>> <action name="hello" class="org.gbif.action.IndexAction"> >>>> <result>/WEB-INF/pages/hello.ftl</result> >>>> </action> >>>> </package> >>>> </code> >>>> >>>> >>>> I have also tried 2 different sitemesh page parsers, HTMLPageParser and >>>> FastPageParser, but that didnt help either. >>>> >>>> Ah, and this is the decorator I am using: >>>> <code> >>>> <?xml version="1.0"?> >>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >>>> <#assign >>>> decorator=JspTaglibs["http://www.opensymphony.com/sitemesh/decorator"] >>>> /> >>>> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> >>>> <head> >>>> <title><@decorator.title default="Struts2 Freemarker Sitemesh >>>> Hibernate"/></title> >>>> <@decorator.head/> >>>> </head> >>>> <body> >>>> <div id="main"> >>>> <@decorator.body/> >>>> </div> <!-- /main --> >>>> </body> >>>> </html> >>>> </code> >>>> >>>> Any idea highly appreciated! >>>> >>>> Markus >>>> >>>> >>>> -- >>>> View this message in context: >>>> http://www.nabble.com/Struts-2.1.6%2C-Sitemesh---FreeMarkerPageFilter-tp21739507p21739507.html >>>> Sent from the Struts - User mailing list archive at Nabble.com. >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>>> For additional commands, e-mail: user-h...@struts.apache.org >>>> >>>> >>> >>> >>> >>> -- >>> "Hey you! Would you help me to carry the stone?" Pink Floyd >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>> For additional commands, e-mail: user-h...@struts.apache.org >>> >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/Struts-2.1.6%2C-Sitemesh---FreeMarkerPageFilter-tp21739507p21745009.html >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > > > > -- > "Hey you! Would you help me to carry the stone?" Pink Floyd > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > -- View this message in context: http://www.nabble.com/Struts-2.1.6%2C-Sitemesh---FreeMarkerPageFilter-tp21739507p21789128.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org