2015-11-10 67 views
1

我在嘗試在keycloak領域註冊新用戶時發生錯誤。我在Mac Yosemite上以獨立模式運行keycloak。我是keycloak的新手,但已成功創建了一個新領域並將其配置爲與本地託管的Apache Web服務器提供的html/js示例頁面一起工作。總之,印象非常深刻;但只想弄清楚我在做這個register.ftl錯誤。Keycloak註冊模板加載錯誤

感謝任何指針。

這裏的錯誤:

22:25:43,034 ERROR [freemarker.runtime] (default task-115) Error executing FreeMarker template: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing: 
==> passwordRequired [in template "register.ftl" at line 46, column 18] 

Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? 

FTL stack trace ("~" means nesting-related): 
    - Failed at: #if passwordRequired [in template "register.ftl" at line 46, column 13] 
    ~ Reached through: #nested "form" [in template "template.ftl" in macro "registrationLayout" at line 72, column 29] 
    ~ Reached through: @layout.registrationLayout; section [in template "register.ftl" at line 2, column 1] 
---- 
at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:131) 
at freemarker.core.UnexpectedTypeException.newDesciptionBuilder(UnexpectedTypeException.java:77) 
    at freemarker.core.UnexpectedTypeException.<init>(UnexpectedTypeException.java:40) 
    at freemarker.core.NonBooleanException.<init>(NonBooleanException.java:44) 
    at freemarker.core.Expression.modelToBoolean(Expression.java:142) 
    at freemarker.core.Expression.evalToBoolean(Expression.java:125) 
    at freemarker.core.Expression.evalToBoolean(Expression.java:110) 
    at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:46) 
    at freemarker.core.Environment.visit(Environment.java:324) 
    at freemarker.core.MixedContent.accept(MixedContent.java:54) 
    at freemarker.core.Environment.visitByHiddingParent(Environment.java:345) 
    at freemarker.core.IfBlock.accept(IfBlock.java:48) 
    at freemarker.core.Environment.visit(Environment.java:324) 
    at freemarker.core.Environment.invokeNestedContent(Environment.java:546) 
    at freemarker.core.BodyInstruction.accept(BodyInstruction.java:56) 
    at freemarker.core.Environment.visit(Environment.java:324) 
    at freemarker.core.MixedContent.accept(MixedContent.java:54) 
    at freemarker.core.Environment.visit(Environment.java:324) 
    at freemarker.core.Macro$Context.runMacro(Macro.java:184) 
    at freemarker.core.Environment.invoke(Environment.java:701) 
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:84) 
    at freemarker.core.Environment.visit(Environment.java:324) 
    at freemarker.core.MixedContent.accept(MixedContent.java:54) 
    at freemarker.core.Environment.visit(Environment.java:324) 
    at freemarker.core.Environment.process(Environment.java:302) 
    at freemarker.template.Template.process(Template.java:325) 
    at <you get the idea...> 
+0

你能後的模板?好像第46行的密碼是必需的,但沒有設置。 –

回答

0

在我的經驗,這主要是由於在形式設置沒有默認/後備值爲空屬性。您可以確保該屬性不能在你的服務被設置爲空或提供一個默認值:

myOptionalVar!myDefault 

或:

<#if myOptionalVar??> 
    when-present 
<#else> 
    when-missing 
</#if>