Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thymeleaf-spring5 ClassNotFoundException ognl/PropertyProcessor #203

tcuje opened this issue Jan 8, 2019 · 4 comments


Copy link

@tcuje tcuje commented Jan 8, 2019

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

Unfortunately the relevant commits do not state why it was excluded, see b6a4911 and 896a147


This comment has been minimized.

Copy link

@ultraq ultraq commented Jan 9, 2019

OGNL is excluded when Thymeleaf is in a Spring project (when including the thymeleaf-spring module) so that the Spring Expression Language (SpEL) is used over OGNL in your templates.

If you've got a Spring Boot project, then this should be taken care of automatically if you import the right starter modules and so no use of OGNL will come up and no ClassNotFoundException should be thrown. If you're using Spring Framework and manually configuring your app to use Thymeleaf, then the setup/configuration is a bit more involved but is described in the Thymeleaf + Spring Tutorial doc which you can find here:


This comment has been minimized.

Copy link

@tcuje tcuje commented Apr 2, 2019

Im using the following package for the project:


It's the only reference to thymeleaf I have in my pom.xml


This comment has been minimized.

Copy link

@mermetbt mermetbt commented May 23, 2019

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


This comment has been minimized.

Copy link

@lurodrig lurodrig commented May 24, 2019

Hello there,

In my case I am using it in a junit test:

import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.thymeleaf.TemplateEngine;

 * @author lurodrig
@SpringBootTest(classes = {MessageFactoryServiceImpl.class,TemplateEngine.class})
public class MessageFactoryServiceTest {
    private String emailAddress;
    private String barcodeText;
    private String registrationLink;
    private String barcodeBase64;
    private MessageFactoryService messageFactoryService;
    public void test_A_emailTextIsRightlyProcessed() {
        Map<String, Object> messageVariables = new HashMap<>();
        messageVariables.put(TemplateConstants.EMAIL_ADDRESS, emailAddress);
        messageVariables.put(TemplateConstants.BARCODE_BASE_64, barcodeBase64);
        messageVariables.put(TemplateConstants.BARCODE_TEXT, barcodeText);
        messageVariables.put(TemplateConstants.REGISTRATION_LINK, registrationLink);
        String message = messageFactoryService.buildVerificationMessage(messageVariables);

The trick of @mermetbt worked for me...


But now I am facing the issue (yet another :) of spring not taking into account the configuration from src/test/resources/ for thymeleaf :(



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.