thymeleaf-spring5 ClassNotFoundException ognl/PropertyProcessor
See original GitHub issueI tried to use thymeleaf in my project, but get the following exception:
java.lang.NoClassDefFoundError: ognl/PropertyAccessor
My versions copied from mvn dependency:tree
org.thymeleaf:thymeleaf-spring5:jar:3.0.11.RELEASE:compile
\- org.thymeleaf:thymeleaf:jar:3.0.11.RELEASE:compile
+- org.attoparser:attoparser:jar:2.0.5.RELEASE:compile
\- org.unbescape:unbescape:jar:1.1.6.RELEASE:compile
I think the issue here is that ognl is excluded by thymeleaf-spring5/pom.xml, see https://github.com/thymeleaf/thymeleaf-spring/blob/3.0-master/thymeleaf-spring5/pom.xml#L318
Unfortunately the relevant commits do not state why it was excluded, see b6a4911 and 896a147
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Spring Boot + Thymeleaf ERROR java.lang ... - Stack Overflow
I got error classnotfoundexception: org.thymeleaf.spring5.ispringtemplateengine when I started upgrading Spring Boot 1.5.14 to Spring Boot ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same issue as you, and adding this solve the problem for me:
After lot of experimentation, following line makes the issue OGNL issue disappear for both Spring and Spring boot:
TemplateEngine templateEngine = new SpringTemplateEngine();
Further, for spring boot to work properly, I had to configure engine as below:
@Bean @Primary public TemplateEngine textTemplateEngine() { TemplateEngine templateEngine = new SpringTemplateEngine(); templateEngine.setTemplateResolver(templateResolver()); return templateEngine; }
As my use case is about simple string replacement in text templates, following is template resolver configuration:
private ITemplateResolver templateResolver() { StringTemplateResolver templateResolver = new StringTemplateResolver(); templateResolver.setTemplateMode(TemplateMode.TEXT); return templateResolver; }