You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to get JTE to work with spring boot, using the examples on the website. However during a production deployment the templates are simply not found/spring boot returns a 404.
During development (from IntelliJ/IDE startup) it works just fine, once the project is compiled into a jar (bootJar target or bootBuildImage) however it just doesn't find the templates.
Including a bunch of attempts at getting the gradle plugin to do something, the closest I got was to have it acutally bundle the .class files into the bootJar, however when that happens it fails to find the JTE "Content" class (even if the dependency is in the libs directory on the final jar).
This is how my gradle build script looks now (relevant parts):
plugins {
id 'java'
id 'io.freefair.lombok' version '8.6'
id 'org.springframework.boot' version '3.4.3'
id 'io.spring.dependency-management' version '1.1.7'
id 'gg.jte.gradle' version '3.1.16'
}
bootJar {
dependsOn(tasks.precompileJte)
from(fileTree("jte-classes") {
include("**/*.class")
})
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'gg.jte:jte:3.1.16'
implementation 'gg.jte:jte-spring-boot-starter-3:3.1.16'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
jte {
precompile()
}
With all that, how are we supposed to actually get this to work? I feel like i've exhausted all my options here besides not using the spring plugin / jte-spring-boot-starter but that doesn't feel right.
To clarify, it works perfectly fine in development mode/on the IDE, but fails in production (bootJar). There are no errors on production (it just results in a 404). With precompilation (as above/gradle) it results in a ClassNotFound for the gg.jte.Content class (even if said class is in spring boot's libs directory).
The text was updated successfully, but these errors were encountered:
The main change is adding the with section to the bootJar target as well as the into directive, this causes gradle to move the class files into the correct locations so that it gets picked up in spring.
This is with the following spring options (using precompiled templates):
While this setup works, looking at the generated bootJar layout, it looks incorrect.
BOOT-INF/
classes/
gg/ <-- This is where they should be, and in this setup they are.
lib/
org/
classes/ <-- This should not be here, it's just the precompiled jte class files
I think either a documentation update or (more likely) changes to the gradle plugin might be worth looking into, this was extremely frustrating to figure out. It's also still not clear to me if I should be using generate() or precompile() target on the jte gradle configuration, given that the bootJar task is the same on development and production and depending on precompileJte while having generate() causes the precompile task to be SKIPPED.
Hey team,
I've been trying to get JTE to work with spring boot, using the examples on the website. However during a production deployment the templates are simply not found/spring boot returns a 404.
During development (from IntelliJ/IDE startup) it works just fine, once the project is compiled into a jar (bootJar target or bootBuildImage) however it just doesn't find the templates.
I've messed around with the options below:
Including a bunch of attempts at getting the gradle plugin to do something, the closest I got was to have it acutally bundle the
.class
files into the bootJar, however when that happens it fails to find the JTE "Content" class (even if the dependency is in the libs directory on the final jar).This is how my gradle build script looks now (relevant parts):
With all that, how are we supposed to actually get this to work? I feel like i've exhausted all my options here besides not using the spring plugin / jte-spring-boot-starter but that doesn't feel right.
To clarify, it works perfectly fine in development mode/on the IDE, but fails in production (bootJar). There are no errors on production (it just results in a 404). With precompilation (as above/gradle) it results in a ClassNotFound for the
gg.jte.Content
class (even if said class is in spring boot's libs directory).The text was updated successfully, but these errors were encountered: