# FTL templates in theme-resources/templates/ not loading in Keycloak-x

**URL:** <https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484>\
**Category:** Extending the server\
**Created:** [February 7, 2022, 8:39pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484 "2022-02-07T20:39:25Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [February 7, 2022, 8:39pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/1 "2022-02-07T20:39:26Z")

</div>

Hi All,

I think I found a bug in Keycloak-x ftl template loading. Posting here to see if anyone is seeing the same behavior. This is a description of an extension that works fine in Keycloak.

1. Place an .ftl template in the `src/main/resorces/theme-resources/templates/` dir of any extension
2. Create an Authenticator or custom REST endpoint that serves the template, like:

```java
  ...
  return session.getProvider(LoginFormsProvider.class).createForm("foo.ftl");
}
...

```

1. Deploy the extension to the `providers/` dir of Keycloak-x (standard distribution or docker)
2. Get the following error, where the template cannot be found:

```auto
2022-02-07 20:06:27,898 ERROR [org.key.for.log.fre.FreeMarkerLoginFormsProvider] (executor-thread-0) Failed to process template: org.keycloak.theme.FreeMarkerException: Failed to process template foo.ftl
	at org.keycloak.theme.FreeMarkerUtil.processTemplate(FreeMarkerUtil.java:71)
	at org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider.processTemplate(FreeMarkerLoginFormsProvider.java:512)
	at org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider.createForm(FreeMarkerLoginFormsProvider.java:302)
	at com.example.FooResourceProvider.foo(FooResourceProvider.java:63)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
	at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
	at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:192)
	at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:141)
	at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:32)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
	at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:135)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:81)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:41)
	at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1193)
	at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
	at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
	at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:67)
	at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:55)
	at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1193)
	at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
	at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
	at io.quarkus.vertx.http.runtime.VertxHttpRecorder$5.handle(VertxHttpRecorder.java:362)
	at io.quarkus.vertx.http.runtime.VertxHttpRecorder$5.handle(VertxHttpRecorder.java:340)
	at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1193)
	at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
	at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
	at org.keycloak.quarkus.runtime.integration.web.QuarkusRequestFilter.lambda$createBlockingHandler$1(QuarkusRequestFilter.java:66)
	at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: freemarker.template.TemplateNotFoundException: Template not found for name "foo.ftl".
The name was interpreted by this TemplateLoader: org.keycloak.theme.FreeMarkerUtil$ThemeTemplateLoader@1e633f79.
	at freemarker.template.Configuration.getTemplate(Configuration.java:2883)
	at freemarker.template.Configuration.getTemplate(Configuration.java:2703)
	at org.keycloak.theme.FreeMarkerUtil.getTemplate(FreeMarkerUtil.java:85)
	at org.keycloak.theme.FreeMarkerUtil.processTemplate(FreeMarkerUtil.java:64)
	... 52 more

```

Does anyone have similar problems?

Thanks!

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [February 25, 2022, 3:28pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/2 "2022-02-25T15:28:50Z")

</div>

This is indeed broken in the new 17.0.0 Quarkus distribution of Keycloak. In order to use `theme-resources` in extensions, you must use a workaround like this:

> <https://github.com/thomasdarimont/keycloak-project-example/blob/main/keycloak/extensionsx/src/main/java/com/github/thomasdarimont/keycloakx/themes/CustomClasspathThemeResourceProviderFactory.java>

Thanks @thomasdarimont !

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [February 25, 2022, 4:04pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/3 "2022-02-25T16:04:52Z")

</div>

Hm… 🤔  
Can‘t repdroduce the error…

I‘m using a custom authenticator with custom .ftl file with my [dasniko/keycloak-2fa-sms-authenticator](https://github.com/dasniko/keycloak-2fa-sms-authenticator). When I deploy this to recent KC17, it works ootb. The template is found and displayed.

What do I do wrong for not getting the error?

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [February 25, 2022, 4:11pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/4 "2022-02-25T16:11:22Z")

</div>

BTW: Your linked file is no more available, Thomas just removed it…!

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [February 25, 2022, 4:19pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/5 "2022-02-25T16:19:01Z")

</div>

Hm. Maybe a bugfix made it into 17. I’ll check to see why it wasn’t working with the pre-release but it’s working now.

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [August 17, 2022, 4:49am UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/6 "2022-08-17T04:49:38Z")

</div>

I’m seeing this back again in `19.0.1`.

@dasniko I tried your sms authenticator and got the following result:

```auto
keycloak_1 | 2022-08-17 04:47:49,350 ERROR [org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider] (executor-thread-14) Failed to process template: org.keycloak.theme.FreeMarkerException: Failed to process template update-mobile-number.ftl
keycloak_1 | at org.keycloak.theme.FreeMarkerUtil.processTemplate(FreeMarkerUtil.java:71)
keycloak_1 | at org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider.processTemplate(FreeMarkerLoginFormsProvider.java:524)
keycloak_1 | at org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider.createForm(FreeMarkerLoginFormsProvider.java:326)
keycloak_1 | at dasniko.keycloak.requiredaction.MobileNumberRequiredAction.createForm(MobileNumberRequiredAction.java:77)
keycloak_1 | at dasniko.keycloak.requiredaction.MobileNumberRequiredAction.requiredActionChallenge(MobileNumberRequiredAction.java:39)
keycloak_1 | at org.keycloak.services.managers.AuthenticationManager.executeAction(AuthenticationManager.java:1310)
keycloak_1 | at org.keycloak.services.managers.AuthenticationManager.lambda$executionActions$18(AuthenticationManager.java:1258)
keycloak_1 | at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
keycloak_1 | at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:400)
keycloak_1 | at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
keycloak_1 | at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
keycloak_1 | at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
keycloak_1 | at java.base/java.util.stream.DistinctOps$1$2.end(DistinctOps.java:168)
keycloak_1 | at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
keycloak_1 | at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:503)
keycloak_1 | at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
keycloak_1 | at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
keycloak_1 | at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
keycloak_1 | at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
keycloak_1 | at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
keycloak_1 | at org.keycloak.services.managers.AuthenticationManager.executionActions(AuthenticationManager.java:1259)
keycloak_1 | at org.keycloak.services.managers.AuthenticationManager.actionRequired(AuthenticationManager.java:1147)
keycloak_1 | at org.keycloak.services.managers.AuthenticationManager.nextActionAfterAuthentication(AuthenticationManager.java:994)
keycloak_1 | at org.keycloak.services.resources.LoginActionsService.processRequireAction(LoginActionsService.java:996)
keycloak_1 | at org.keycloak.services.resources.LoginActionsService.requiredActionGET(LoginActionsService.java:978)
keycloak_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
keycloak_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
keycloak_1 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
keycloak_1 | at java.base/java.lang.reflect.Method.invoke(Method.java:566)
keycloak_1 | at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
keycloak_1 | at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
keycloak_1 | at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
keycloak_1 | at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
keycloak_1 | at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
keycloak_1 | at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
keycloak_1 | at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
keycloak_1 | at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
keycloak_1 | at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:192)
keycloak_1 | at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:141)
keycloak_1 | at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:32)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
keycloak_1 | at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
keycloak_1 | at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
keycloak_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
keycloak_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:82)
keycloak_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:42)
keycloak_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
keycloak_1 | at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:67)
keycloak_1 | at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:55)
keycloak_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
keycloak_1 | at io.quarkus.vertx.http.runtime.VertxHttpRecorder$5.handle(VertxHttpRecorder.java:380)
keycloak_1 | at io.quarkus.vertx.http.runtime.VertxHttpRecorder$5.handle(VertxHttpRecorder.java:358)
keycloak_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
keycloak_1 | at org.keycloak.quarkus.runtime.integration.web.QuarkusRequestFilter.lambda$createBlockingHandler$1(QuarkusRequestFilter.java:90)
keycloak_1 | at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
keycloak_1 | at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
keycloak_1 | at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
keycloak_1 | at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:545)
keycloak_1 | at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
keycloak_1 | at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
keycloak_1 | at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
keycloak_1 | at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
keycloak_1 | at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
keycloak_1 | at java.base/java.lang.Thread.run(Thread.java:829)
keycloak_1 | Caused by: freemarker.template.TemplateNotFoundException: Template not found for name "update-mobile-number.ftl".
keycloak_1 | The name was interpreted by this TemplateLoader: org.keycloak.theme.FreeMarkerUtil$ThemeTemplateLoader@418d109c.
keycloak_1 | at freemarker.template.Configuration.getTemplate(Configuration.java:2883)
keycloak_1 | at freemarker.template.Configuration.getTemplate(Configuration.java:2703)
keycloak_1 | at org.keycloak.theme.FreeMarkerUtil.getTemplate(FreeMarkerUtil.java:85)
keycloak_1 | at org.keycloak.theme.FreeMarkerUtil.processTemplate(FreeMarkerUtil.java:58)
keycloak_1 | ... 73 more
keycloak_1 |
keycloak_1 | 2022-08-17 04:47:49,354 ERROR [org.keycloak.headers.DefaultSecurityHeadersProvider] (executor-thread-14) MediaType not set on path /auth/realms/self/login-actions/required-action, with response status 500
keycloak_1 | 2022-08-17 04:47:49,367 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-14) Uncaught server error: javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
keycloak_1 | at org.keycloak.headers.DefaultSecurityHeadersProvider.addHeaders(DefaultSecurityHeadersProvider.java:75)
keycloak_1 | at org.keycloak.services.filters.KeycloakSecurityHeadersFilter.filter(KeycloakSecurityHeadersFilter.java:40)
keycloak_1 | at org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl.filter(ContainerResponseContextImpl.java:361)
keycloak_1 | at org.jboss.resteasy.core.ServerResponseWriter.executeFilters(ServerResponseWriter.java:252)
keycloak_1 | at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:101)
keycloak_1 | at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:74)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:594)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
keycloak_1 | at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
keycloak_1 | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
keycloak_1 | at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
keycloak_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
keycloak_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:82)
keycloak_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:42)
keycloak_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
keycloak_1 | at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:67)
keycloak_1 | at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:55)
keycloak_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
keycloak_1 | at io.quarkus.vertx.http.runtime.VertxHttpRecorder$5.handle(VertxHttpRecorder.java:380)
keycloak_1 | at io.quarkus.vertx.http.runtime.VertxHttpRecorder$5.handle(VertxHttpRecorder.java:358)
keycloak_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
keycloak_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
keycloak_1 | at org.keycloak.quarkus.runtime.integration.web.QuarkusRequestFilter.lambda$createBlockingHandler$1(QuarkusRequestFilter.java:90)
keycloak_1 | at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
keycloak_1 | at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
keycloak_1 | at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
keycloak_1 | at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:545)
keycloak_1 | at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
keycloak_1 | at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
keycloak_1 | at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
keycloak_1 | at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
keycloak_1 | at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
keycloak_1 | at java.base/java.lang.Thread.run(Thread.java:829)
keycloak_1 |

```

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [August 17, 2022, 5:00am UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/7 "2022-08-17T05:00:41Z")

</div>

Bug filed:

> <https://github.com/keycloak/keycloak/issues/13825>
>
> \### Describe the bug
> 
> FTL templates placed in \`src/main/resorces/theme-resources…/templates/\` are not found by extensions using \`LoginFormsProvider\` or \`EmailTemplateProvider\`.
> 
> \### Version
> 
> 19.0.1
> 
> \### Expected behavior
> 
> According to https://www.keycloak.org/docs/latest/server\_development/#\_theme\_resource
> \> The easiest way to load additional theme resources is to create a JAR with templates in theme-resources/templates resources in theme-resources/resources and messages bundles in theme-resources/messages.
> 
> Based on observation of previous behavior
> 
> 1. using this in an authenticator or resource 
> \`\`\`
> session.getProvider(LoginFormsProvider.class).createForm("update-mobile-number.ftl");
> \`\`\`
> should load the template in \`theme-resources/templates/update-mobile-number.ftl\`.
> 
> 2. using this when sending an email
> \`\`\`
> session.getProvider(EmailTemplateProvider.class)
> .setRealm(realm)
> .setUser(user)
> .send(subjectKey, subjectAttributes, "mobile-updated.ftl", bodyAttributes);
> \`\`\`
> should load the templates in \`theme-resources/templates/html/mobile-updated.ftl\` and \`theme-resources/templates/text/mobile-updated.ftl\`.
> 
> \### Actual behavior
> 
> Template cannot be processed because it cannot be found:
> 
> \`\`\`
> keycloak\_1 | 2022-08-17 04:47:49,350 ERROR \[org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider\] (executor-thread-14) Failed to process template: org.keycloak.theme.FreeMarkerException: Failed to process template update-mobile-number.ftl
> keycloak\_1 | at org.keycloak.theme.FreeMarkerUtil.processTemplate(FreeMarkerUtil.java:71)
> keycloak\_1 | at org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider.processTemplate(FreeMarkerLoginFormsProvider.java:524)
> keycloak\_1 | at org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider.createForm(FreeMarkerLoginFormsProvider.java:326)
> keycloak\_1 | at dasniko.keycloak.requiredaction.MobileNumberRequiredAction.createForm(MobileNumberRequiredAction.java:77)
> keycloak\_1 | at dasniko.keycloak.requiredaction.MobileNumberRequiredAction.requiredActionChallenge(MobileNumberRequiredAction.java:39)
> keycloak\_1 | at org.keycloak.services.managers.AuthenticationManager.executeAction(AuthenticationManager.java:1310)
> keycloak\_1 | at org.keycloak.services.managers.AuthenticationManager.lambda$executionActions$18(AuthenticationManager.java:1258)
> keycloak\_1 | at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
> keycloak\_1 | at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:400)
> keycloak\_1 | at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
> keycloak\_1 | at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
> keycloak\_1 | at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
> keycloak\_1 | at java.base/java.util.stream.DistinctOps$1$2.end(DistinctOps.java:168)
> keycloak\_1 | at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
> keycloak\_1 | at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:503)
> keycloak\_1 | at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
> keycloak\_1 | at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
> keycloak\_1 | at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
> keycloak\_1 | at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
> keycloak\_1 | at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
> keycloak\_1 | at org.keycloak.services.managers.AuthenticationManager.executionActions(AuthenticationManager.java:1259)
> keycloak\_1 | at org.keycloak.services.managers.AuthenticationManager.actionRequired(AuthenticationManager.java:1147)
> keycloak\_1 | at org.keycloak.services.managers.AuthenticationManager.nextActionAfterAuthentication(AuthenticationManager.java:994)
> keycloak\_1 | at org.keycloak.services.resources.LoginActionsService.processRequireAction(LoginActionsService.java:996)
> keycloak\_1 | at org.keycloak.services.resources.LoginActionsService.requiredActionGET(LoginActionsService.java:978)
> keycloak\_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> keycloak\_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> keycloak\_1 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> keycloak\_1 | at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> keycloak\_1 | at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
> keycloak\_1 | at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
> keycloak\_1 | at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
> keycloak\_1 | at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
> keycloak\_1 | at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
> keycloak\_1 | at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
> keycloak\_1 | at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
> keycloak\_1 | at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
> keycloak\_1 | at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:192)
> keycloak\_1 | at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:141)
> keycloak\_1 | at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:32)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
> keycloak\_1 | at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
> keycloak\_1 | at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
> keycloak\_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
> keycloak\_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:82)
> keycloak\_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:42)
> keycloak\_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
> keycloak\_1 | at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:67)
> keycloak\_1 | at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:55)
> keycloak\_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
> keycloak\_1 | at io.quarkus.vertx.http.runtime.VertxHttpRecorder$5.handle(VertxHttpRecorder.java:380)
> keycloak\_1 | at io.quarkus.vertx.http.runtime.VertxHttpRecorder$5.handle(VertxHttpRecorder.java:358)
> keycloak\_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
> keycloak\_1 | at org.keycloak.quarkus.runtime.integration.web.QuarkusRequestFilter.lambda$createBlockingHandler$1(QuarkusRequestFilter.java:90)
> keycloak\_1 | at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
> keycloak\_1 | at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
> keycloak\_1 | at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
> keycloak\_1 | at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:545)
> keycloak\_1 | at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
> keycloak\_1 | at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
> keycloak\_1 | at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
> keycloak\_1 | at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
> keycloak\_1 | at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> keycloak\_1 | at java.base/java.lang.Thread.run(Thread.java:829)
> keycloak\_1 | Caused by: freemarker.template.TemplateNotFoundException: Template not found for name "update-mobile-number.ftl".
> keycloak\_1 | The name was interpreted by this TemplateLoader: org.keycloak.theme.FreeMarkerUtil$ThemeTemplateLoader@418d109c.
> keycloak\_1 | at freemarker.template.Configuration.getTemplate(Configuration.java:2883)
> keycloak\_1 | at freemarker.template.Configuration.getTemplate(Configuration.java:2703)
> keycloak\_1 | at org.keycloak.theme.FreeMarkerUtil.getTemplate(FreeMarkerUtil.java:85)
> keycloak\_1 | at org.keycloak.theme.FreeMarkerUtil.processTemplate(FreeMarkerUtil.java:58)
> keycloak\_1 | ... 73 more
> keycloak\_1 |
> keycloak\_1 | 2022-08-17 04:47:49,354 ERROR \[org.keycloak.headers.DefaultSecurityHeadersProvider\] (executor-thread-14) MediaType not set on path /auth/realms/self/login-actions/required-action, with response status 500
> keycloak\_1 | 2022-08-17 04:47:49,367 ERROR \[org.keycloak.services.error.KeycloakErrorHandler\] (executor-thread-14) Uncaught server error: javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
> keycloak\_1 | at org.keycloak.headers.DefaultSecurityHeadersProvider.addHeaders(DefaultSecurityHeadersProvider.java:75)
> keycloak\_1 | at org.keycloak.services.filters.KeycloakSecurityHeadersFilter.filter(KeycloakSecurityHeadersFilter.java:40)
> keycloak\_1 | at org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl.filter(ContainerResponseContextImpl.java:361)
> keycloak\_1 | at org.jboss.resteasy.core.ServerResponseWriter.executeFilters(ServerResponseWriter.java:252)
> keycloak\_1 | at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:101)
> keycloak\_1 | at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:74)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:594)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
> keycloak\_1 | at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
> keycloak\_1 | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
> keycloak\_1 | at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
> keycloak\_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
> keycloak\_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:82)
> keycloak\_1 | at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:42)
> keycloak\_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
> keycloak\_1 | at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:67)
> keycloak\_1 | at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:55)
> keycloak\_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
> keycloak\_1 | at io.quarkus.vertx.http.runtime.VertxHttpRecorder$5.handle(VertxHttpRecorder.java:380)
> keycloak\_1 | at io.quarkus.vertx.http.runtime.VertxHttpRecorder$5.handle(VertxHttpRecorder.java:358)
> keycloak\_1 | at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
> keycloak\_1 | at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
> keycloak\_1 | at org.keycloak.quarkus.runtime.integration.web.QuarkusRequestFilter.lambda$createBlockingHandler$1(QuarkusRequestFilter.java:90)
> keycloak\_1 | at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
> keycloak\_1 | at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
> keycloak\_1 | at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
> keycloak\_1 | at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:545)
> keycloak\_1 | at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
> keycloak\_1 | at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
> keycloak\_1 | at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
> keycloak\_1 | at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
> keycloak\_1 | at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> keycloak\_1 | at java.base/java.lang.Thread.run(Thread.java:829)
> \`\`\`
> 
> \### How to Reproduce?
> 
> 1. Place an .ftl template in the src/main/resorces/theme-resources/templates/ dir of any extension
> 2. Create an Authenticator or custom REST endpoint that serves the template, like:
> \`\`\`
> ...
> return session.getProvider(LoginFormsProvider.class).createForm("update-mobile-number.ftl");
> }
> ...
> \`\`\`
> 3. Deploy the extension to the providers/ dir (standard distribution or docker)
> 4. Use the functionality that will cause the templating function to be invoked.
> 
> 
> \### Anything else?
> 
> \_No response\_

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [August 17, 2022, 6:00am UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/8 "2022-08-17T06:00:02Z")

</div>

Thanks @xgp for coming up with this.  
I didn’t have time yet to test all my extensions, I only noticed that the sms authenticator doesn’t work, without investigating why. But it seems that you are right, no changes in code and it doesn’t work with 19+

With this behavior and the fact that the new admin ui is more than buggy, I can’t recommend upgrading to KC19 atm. Dissappointing.

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [August 17, 2022, 8:45am UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/9 "2022-08-17T08:45:08Z")

</div>

Seems there is already a fix available, so we have to wait for the next release (hopefully soon a patch release). 🙂

**Workaround:**  
If you use a custom theme, put the resources/template files into your custom theme, then they will be found.

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [August 17, 2022, 3:24pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/10 "2022-08-17T15:24:44Z")

</div>

@dasniko Thanks. I ran the nightly and the fix works.

Thanks for the workaround. I already had done that for my own use. I was more concerned about people that were using extensions I have shipped.

---

<div class="post-metadata">

**Author:** ![MrLebovsky](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/mrlebovsky/32/6382_2.png) [@MrLebovsky](https://forum.keycloak.org/u/MrLebovsky)\
**Post date:** [August 18, 2022, 11:59am UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/11 "2022-08-18T11:59:46Z")

</div>

Hi All,

I’ve got the same error using any of 17, 18 or 19 KC version. Freemarker just cannot find templates in resources/theme-resources directory.  
CustomClasspathThemeResourceProviderFactory does not work for me.  
Maybe I do smth wrong?

I’m using embedded keyclok from [here](https://github.com/thomasdarimont/embedded-spring-boot-keycloak-server) and @dasniko 's [2FA Example](https://github.com/dasniko/keycloak-2fa-sms-authenticator) .

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [August 18, 2022, 1:05pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/12 "2022-08-18T13:05:19Z")

</div>

> [@MrLebovsky](#):
>
> Maybe I do smth wrong?

Yes, most probably.

But what? We don’t know, you don’t tell us anything.  
Also, this embedded KC stuff is very experimental (and I don’t have any clue about this).

---

<div class="post-metadata">

**Author:** ![MrLebovsky](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/mrlebovsky/32/6382_2.png) [@MrLebovsky](https://forum.keycloak.org/u/MrLebovsky)\
**Post date:** [August 18, 2022, 2:37pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/13 "2022-08-18T14:37:21Z")

</div>

@dasniko tell pls, what would you recommend to use for KC customization?  
Download sources, put custom provider to special folders and then build?

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [August 18, 2022, 4:06pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/14 "2022-08-18T16:06:02Z")

</div>

> Download sources

No, don‘t (never) deal with the sources! Take the compiled binaries or the Docker image!

> put custom provider to special folders and then build

Yes, create your providers, compile them to a `.jar` file, put this into the `/opt/keycloak/providers` folder (when using Docker, in case of deployment into filesystem, look for the `providers` folder under the KC root folder), then start/build the Keycloak image (see docs what „build“ is meant here).

---

<div class="post-metadata">

**Author:** ![MrLebovsky](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/mrlebovsky/32/6382_2.png) [@MrLebovsky](https://forum.keycloak.org/u/MrLebovsky)\
**Post date:** [August 19, 2022, 5:42am UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/15 "2022-08-19T05:42:45Z")

</div>

Oh got it. Thanks @dasniko !

Could you tell me another thing: how could I use your 2FA with oauth2 authorization? I mean case when client do request for getting jwt token and then pass it to rest api’s to get access?

---

<div class="post-metadata">

**Author:** ![sreenivas572](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sreenivas572](https://forum.keycloak.org/u/sreenivas572)\
**Post date:** [February 14, 2024, 12:55pm UTC](https://forum.keycloak.org/t/ftl-templates-in-theme-resources-templates-not-loading-in-keycloak-x/13484/17 "2024-02-14T12:55:09Z")

</div>

With KC23 i am seeing the same issue. Unable to load the template. I have wrapped it in the jar file and then went to the build folder and executed: kc.bat build. Later when I am triggering the login, it still says internal error. And the in the KC logs, I could see exception that org.keycloak.forms.login.LoginFormsProvider.createForm(java.lang.String) noSuchMethodError.

When I went back to see the KC documentation, I could not see the createForm method which was available in earlier version. @dasniko Can you please help with the latest version of KC here please.
