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'm encountering an issue when trying to render a Thymeleaf template in an async context. After starting the async context, I'm getting the following exception:
java.lang.IllegalArgumentException: Cannot build an application for a request which servlet context does not match with the application that it is being built for.
at org.thymeleaf.util.Validate.isTrue(Validate.java:79)
at org.thymeleaf.web.servlet.JakartaServletWebApplication.buildExchange(JakartaServletWebApplication.java:61)
at io.javalin.rendering.template.JavalinThymeleaf.render(JavalinThymeleaf.kt:28)
at io.javalin.rendering.JavalinRenderer.renderBasedOnExtension(JavalinRenderer.kt:32)
at io.javalin.rendering.LegacyFileRenderer.render(JavalinRenderer.kt:19)
at io.javalin.http.Context.render(Context.kt:452)
at io.javalin.TestTemplates.thymeleaf_templates_work_in_async$lambda-15$lambda-14$lambda-13(TestTemplates.kt:75)
at io.javalin.http.util.AsyncUtil.submitAsyncTask$lambda-4$lambda-0(AsyncUtil.kt:29)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
My rendering code is here:
overridefunrender(filePath:String, model:Map<String, Any?>, ctx:Context): String {
// ctx.req().servletContext that is passed to buildApplication has to match ctx.req().servletContext passed into// buildExchange. (application.servletContext === ctx.req().servletContext)val application =JakartaServletWebApplication.buildApplication(ctx.req().servletContext)
val webExchange = application.buildExchange(ctx.req(), ctx.res())
val context =WebContext(webExchange, webExchange.locale, model)
return templateEngine.process(filePath, context)
}
I can't find any information about using Thymeleaf in an async context anywhere. Is this supported somehow?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm encountering an issue when trying to render a Thymeleaf template in an async context. After starting the async context, I'm getting the following exception:
My rendering code is here:
I can't find any information about using Thymeleaf in an async context anywhere. Is this supported somehow?
Beta Was this translation helpful? Give feedback.
All reactions