Error Resolving Template in a packaged jar

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Error Resolving Template in a packaged jar

Aleix
This post was updated on .
I have a Spring Boot application using Thymeleaf 2.1.6, which works fine when debugging from NetBeans, but gives me this error running its .jar:

Error resolving template "/theme/property", template might not exist or might not be accessible by any of the configured Template Resolvers

The app is set to auto-configurer with the annotation @SpringBootApplication, at an extension of SpringBootServletInitializer. I haven't set any contextPath into the properties file.

Doing some research I've come out that in some controllers I was passing a double slash, which I've solved but most pages still not working.

I have placed this question about it in Stack Overflow, with some extracts of my code and the templates structure:

https://stackoverflow.com/questions/48400967/error-resolving-template-with-spring-boot-using-thymeleaf-packaged-in-a-jar

Deploying the jar into Pivotal Web Services the whole website works fine, but not deploying it in Heroku or running the jar locally. Therefore, I guess the origin of the problem is some wrong configuration, that Pivotal system detects and corrects.

I would appreciate very much any help, to solve this issue. Thanks

Aleix Alcover
Reply | Threaded
Open this post in threaded view
|

Re: Error Resolving Template in a packaged jar

Aleix
This post was updated on .
At the end I've found a solution to the problem. It was related with the double slash, that the classpath:/templates/ takes if at a controller we set a return statement with a slash, as:

return "/my-page"

In my case those double slashes where in the html:

<footer th:replace="/index::footer"></footer> instead of:

<footer th:replace="index::footer"></footer>

Anyway, what I don't know is why in the IDE was working and running the jar not.

Reply | Threaded
Open this post in threaded view
|

Re: Error Resolving Template in a packaged jar

bjsp2217
it is very helpful, i met the same issue and resolve by your solution, thanks a lot, i just register this ID to thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Error Resolving Template in a packaged jar

Aleix
You are welcome