You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
If I'm using a direct deployment of Tomcat without using Gretty, I don't get the exception.
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.
Hey there, sorry to take so long getting back to you on this one as this is an interesting bug and had me stumped for a very long time. However, I gave it another look this weekend and found the issue.
The Gretty plugin is written against Groovy 3, and introduces Groovy 3 JARs into the classloader of the servlet container that is being launched (Tomcat 10 in this case). However, version 3.1.0 and newer of the Thymeleaf Layout Dialect is written in Groovy 4, and so this mixup of Groovy versions causes the issues that you're seeing.
The only workarounds I can think of right now are:
to run Tomcat directly (as you've found, this doesn't cause the issue)
to use the Java-only port of the layout dialect by zhanhb
to use a version of the layout dialect before the move to Groovy 4, like version 3.0.0 (I've tested this using your example project and it works)
or, since you're using Spring, to use something like Spring Boot so that Tomcat can be bundled with your project and also includes a Gradle plugin to use in your build file
I hope that gives you some options to consider. Thank you again for the bug report and the example project which helped me figure out what was going on 🙇♂️
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
My project environment looks like this
3.1.1.RELEASE
3.2.1
4.0.3
10.1.10
When I run the web project, I run it with the command below.
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
If I'm using a direct deployment of Tomcat without using Gretty, I don't get the exception.
If I use
https://github.com/zhanhb/thymeleaf-layout-dialect
, there's no problem running a web project with Gretty.✨ Example project to see the problem
I've created an example project for you to see the issue.
Example project github url
Example project Zip File
How to run
Run with Gretty
Accessing the layout page in a web browser
http://localhost:8090/main
Thank you. Have a nice day. 👍
The text was updated successfully, but these errors were encountered: