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

Class not found exception for spring boot template engine #301

Open
Hazar6160 opened this issue Jul 26, 2022 · 2 comments
Open

Class not found exception for spring boot template engine #301

Hazar6160 opened this issue Jul 26, 2022 · 2 comments

Comments

@Hazar6160
Copy link

Hello,

I've been upgraded spring boot version to 2.6.6, After that I am having a issue with template engine. It is throwing a java.lang.ClassNotFoundException: ognl.DefaultMemberAccess exception. Currently we are using a below dependencies for thymeleaf template engine. Anybody help me to resolve this issue?

            <dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-thymeleaf</artifactId>
	</dependency>
	<dependency>
		<groupId>ognl</groupId>
		<artifactId>ognl</artifactId>
		<version>3.3.2</version>
	</dependency>
@ultraq
Copy link
Member

ultraq commented Jul 26, 2022

Hi there, one thing that looks odd to me is that, when you're using Thymeleaf with Spring or Spring Boot, OGNL shouldn't be needed as a dependency any more. Spring Boot usually takes care of this configuration, so you might want to compare your project to some simple Spring Boot + Thymeleaf tutorials/projects out there.

For example, the Spring Boot website has a guide for setting up a Spring Boot project w/ Thymeleaf and includes an example application and GitHub repo. Looking at their pom.xml file in https://github.com/spring-guides/gs-serving-web-content/blob/main/complete/pom.xml, I can see only Spring Boot dependencies listed:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</dependency>

While that example repo is now using Spring Boot 2.7.1, I've found that the dependencies have remained largely the same across Spring Boot 2.x versions.

@Hazar6160
Copy link
Author

I've tried without ognl dependency, but still throwing a same issue.

Spring boot I am using 2.7.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants