question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

thymeleaf-spring5 ClassNotFoundException ognl/PropertyProcessor

See original GitHub issue

I 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:open
  • Created 5 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

22reactions
mermetbtcommented, May 23, 2019

I had the same issue as you, and adding this solve the problem for me:

        <dependency>
            <groupId>ognl</groupId>
            <artifactId>ognl</artifactId>
            <version>3.1.12</version>
        </dependency>
9reactions
amanbholecommented, Nov 12, 2020

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; }

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found