Error resolving JSP template with Tiles (TL Extras Tiles 2)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Error resolving JSP template with Tiles (TL Extras Tiles 2)

Eric Francis
My package structure is

/webapp/
  /layout/
  /WEB-INF/

While trying to resolve this Tiles definition:

<definition name="banner.layout.definition"
                template="/layout/layoutTwo.jsp" templateType="jsp" extends="root.layout.definition">


I am seeing this error:

INFO: [THYMELEAF][tomcat-http--7] Exception processing template "/layout/layoutTwoCol.jsp": Error resolving template "layout/layoutTwo.jsp", template might not exist or might not be accessible by any of the configured Template Resolvers
INFO   | jvm 1    | 2013/04/25 16:00:17 |
Apr 25, 2013 4:00:17 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [tl] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.Templ
ateInputException: Error resolving template "/layout/layoutTwoCol.jsp", template might not exist or might not be accessible by any of the configured Template Resolvers] with root ca
use
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/layout/layoutTwoCol.jsp", template might not exist or might not
 be accessible by any of the configured Template Resolvers
      at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:247)
      at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1192)
      at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1148)
      at org.thymeleaf.extras.tiles2.renderer.ThymeleafAttributeRenderer.write(ThymeleafAttributeRenderer.java:149)
      at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
      at org.thymeleaf.extras.tiles2.renderer.MetadataCleaningAttributeRendererWrapper.render(MetadataCleaningAttributeRendererWrapper.java:111)

I feel like thymeleaf should be able to locate the correct jsp. I am not sure how to troubleshoot this.

Thanks!


Reply | Threaded
Open this post in threaded view
|

Re: Error resolving JSP template with Tiles (TL Extras Tiles 2)

Eric Francis
I just noticed this thread: Chaining View Resolvers

I will try this.



Reply | Threaded
Open this post in threaded view
|

Re: Error resolving JSP template with Tiles (TL Extras Tiles 2)

danielfernandez
Administrator
Thymeleaf shouldn't be trying to resolve your JSP at all, since you are using Tiles and setting "templateType="jsp"" in your definition.

Maybe your problem is a path one. Think that JSP paths in Tiles are servlet-context-relative, and therefore should start with "/WEB-INF" if they are inside such directory...

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: Error resolving JSP template with Tiles (TL Extras Tiles 2)

Eric Francis
So Tiles can for sure resolve jsp templates?

My jsp layouts are directly under /webapp/
Reply | Threaded
Open this post in threaded view
|

Re: Error resolving JSP template with Tiles (TL Extras Tiles 2)

Eric Francis
This is my spring config:

@Configuration
@EnableWebMvc
@ComponentScan("com.thymeleaf.poc.controller")
public class ThymeleafSpringJavaConfig {

        static final Logger logger = LoggerFactory.getLogger(ThymeleafSpringJavaConfig.class);

        @Bean
        public ServletContextTemplateResolver thymeleafTemplateResolver() {
                ServletContextTemplateResolver thymeleafTemplateResolver = new ServletContextTemplateResolver();
                thymeleafTemplateResolver.setPrefix("/WEB-INF/thymeleaf/");
                thymeleafTemplateResolver.setSuffix(".html");
                thymeleafTemplateResolver.setTemplateMode("HTML5");
                thymeleafTemplateResolver.setOrder(1);
                return thymeleafTemplateResolver;
        }

        @Bean
        public ITemplateResolver jspTemplateResolver() {
                //Do I Need something here???

                return null;
        }


        @Bean
        public SpringTemplateEngine thymeleafTemplateEngine() {
                SpringTemplateEngine templateEngine = new SpringTemplateEngine();
                addTemlplateResolvers(templateEngine);
                addDialects(templateEngine);
                return templateEngine;
        }

        private void addDialects(SpringTemplateEngine templateEngine) {
                Set<IDialect> dialects = new HashSet<IDialect>();
                dialects.add(tiles2Dialect());
                templateEngine.setAdditionalDialects(dialects);

        }

        private void addTemlplateResolvers(SpringTemplateEngine templateEngine) {
                Set<ITemplateResolver> templateResolvers = new HashSet<ITemplateResolver>();
                templateResolvers.add(thymeleafTemplateResolver());
                templateResolvers.add(jspTemplateResolver());
                templateEngine.setTemplateResolvers(templateResolvers);
        }

        @Bean
        public ThymeleafViewResolver tilesViewResolver() {
                ThymeleafViewResolver tilesViewResolver = new ThymeleafViewResolver();
                tilesViewResolver.setViewClass(ThymeleafTilesView.class);
                tilesViewResolver.setTemplateEngine(thymeleafTemplateEngine());
                tilesViewResolver.setOrder(0);
                return tilesViewResolver;
        }

        @Bean
        public ThymeleafTilesConfigurer tilesConfigurer() {
                ThymeleafTilesConfigurer tilesConfigurer = new ThymeleafTilesConfigurer();
                String[] definitions = { "/WEB-INF/**/tiles-thymeleaf.xml" };
                tilesConfigurer.setDefinitions(definitions);
                return tilesConfigurer;
        }

        @Bean
        public TilesDialect tiles2Dialect() {
                return new TilesDialect();
        }

        @Bean
        SpringStandardDialect spring3Dialect() {
                return new SpringStandardDialect();
        }
}
Reply | Threaded
Open this post in threaded view
|

Re: Error resolving JSP template with Tiles (TL Extras Tiles 2)

Eric Francis
Ok, I removed:

                thymeleafTemplateResolver.setPrefix("/WEB-INF/thymeleaf/");
                thymeleafTemplateResolver.setSuffix(".html");

And I have gotten passed my problem.