Skip to content

When using Gretty with the Thymeleaf Layout Dialect, an exception was thrown when visiting a layout-applied page. #237

@mklinkj

Description

@mklinkj

Hello.

When running the web server with Gretty.. When accessing the layout page, the following exception is exposed and nothing appears on the web browser screen.

  • Exception Log

    Caused by: java.lang.ClassCastException: class nz.net.ultraq.thymeleaf.layoutdialect.models.extensions.EventIterator cannot be cast to class [Ljava.lang.Object; (nz.net.ultraq.thymeleaf.layoutdialect.models.extensions.EventIterator is in unnamed module of loader java.net.URLClassLoader @889d9e8; [Ljava.lang.Object; is in module java.base of loader 'bootstrap')
            at org.codehaus.groovy.runtime.dgm$236.doMethodInvoke(Unknown Source) ~[groovy-4.0.10.jar:4.0.10]
            at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321) ~[groovy-4.0.10.jar:4.0.10]
            at nz.net.ultraq.thymeleaf.layoutdialect.models.extensions.IModelExtensions.find(IModelExtensions.groovy:117) ~[thymeleaf-layout-dialect-3.2.1.jar:?]
            ...
    

My project environment looks like this

  • Spring 6 (Not Spring Boot )
  • Thymeleaf
    • thymeleaf-spring6: 3.1.1.RELEASE
    • thymeleaf-layout-dialect: 3.2.1
  • Gretty 4.0.3
    • Tomcat 10.1.10

When I run the web project, I run it with the command below.

gradle clean appRun

When I ran Gretty and accessed the page with the layout applied, I definitely saw the aforementioned exception.

However, there are two things that are unusual.

✨ Two unusual things

  1. If I'm using a direct deployment of Tomcat without using Gretty, I don't get the exception.

  2. If I use https://github.com/zhanhb/thymeleaf-layout-dialect, there's no problem running a web project with Gretty.

      // TODO: Using gretty with thymeleaf-layout-dialect causes an exception
      implementation "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:${thymeleafLayoutVersion}"
      // TODO: If I use the thymeleaf-layout-dialect modified by zhanhb, the exception does not occur.
      // implementation "com.github.zhanhb:thymeleaf-layout-dialect:${zhanhbThymeleafLayoutVersion}"

✨ Example project to see the problem

I've created an example project for you to see the issue.

Thank you. Have a nice day. 👍

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions