<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div style="font-size: 12.0px;font-family: standard;">Hy everyone!</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;</div>

<div style="font-size: 12.0px;font-family: standard;">We are trying to secure an embedded restfull Jetty-Application with Keycloak. We have&nbsp;</div>

<div style="font-size: 12.0px;font-family: standard;">managed to redirect to the Keycloak server when a secured area on our webservice is called as also our service is called/redirected to, after login.&nbsp;</div>

<div style="font-size: 12.0px;font-family: standard;">However after successfull login, we get an NullPointerException (below).&nbsp;</div>

<div style="font-size: 12.0px;font-family: standard;">What we have debugged so far: Stateless is required, therefore we are using cookie-tokenstore. The informations are set correctly to the cookie. However it seams this informations are not assigned to/by the adapter during the redirect request.</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;</div>

<div style="font-size: 12.0px;font-family: standard;">Did anyone run into the same error? Any help/hint would be appreciated! Thanks</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;</div>

<div style="font-size: 12.0px;font-family: standard;">[WARN ] 2016-02-15 16:29:55.884 [pool-2-thread-18] HttpChannel - /</div>

<div style="font-size: 12.0px;font-family: standard;">java.lang.NullPointerException</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at org.keycloak.adapters.jetty.core.AbstractKeycloakJettyAuthenticator.createIdentity(AbstractKeycloakJettyAuthenticator.java:110) ~[keycloak-jetty-core-1.8.1.Final.jar:1.8.1.Final]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at org.keycloak.adapters.jetty.core.AbstractKeycloakJettyAuthenticator.register(AbstractKeycloakJettyAuthenticator.java:289) ~[keycloak-jetty-core-1.8.1.Final.jar:1.8.1.Final]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at org.keycloak.adapters.jetty.core.AbstractKeycloakJettyAuthenticator.validateRequest(AbstractKeycloakJettyAuthenticator.java:257) ~[keycloak-jetty-core-1.8.1.Final.jar:1.8.1.Final]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:512) ~[jetty-security-9.2.10.v20150310.jar:9.2.10.v20150310]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at org.eclipse.jetty.server.Server.handle(Server.java:497) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at org.eclipse.jetty.io.AbstractConnection&#36;2.run(AbstractConnection.java:540) [jetty-io-9.2.10.v20150310.jar:9.2.10.v20150310]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_72]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at java.util.concurrent.ThreadPoolExecutor&#36;Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_72]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;at java.lang.Thread.run(Thread.java:745) [?:1.8.0_72]</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;</div>

<div style="font-size: 12.0px;font-family: standard;">Our adapterconfiguration looks like this:</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;KeycloakJettyAuthenticator keycloakAuthenticator = new KeycloakJettyAuthenticator();</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;AdapterConfig keycloakAdapterConfig = new AdapterConfig();</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;keycloakAdapterConfig.setRealm(&quot;myRealm&quot;);</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;keycloakAdapterConfig.setRealmKey(&quot;MIIBIjANB ... RsvQIDAQAB&quot;);</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;keycloakAdapterConfig.setAuthServerUrl(&quot;<a href="https://3c.gmx.net/mail/client/dereferrer?redirectUrl=http%3A%2F%2Flocalhost%3A8080%2Fauth%2522" target="_blank">http://localhost:8080/auth&quot;</a>);</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;keycloakAdapterConfig.setSslRequired(&quot;external&quot;);</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;keycloakAdapterConfig.setResource(&quot;myRealmClient&quot;);</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;keycloakAdapterConfig.setPublicClient(true);</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;keycloakAdapterConfig.setUseResourceRoleMappings(true);</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;keycloakAdapterConfig.setTokenStore(&quot;cookie&quot;);</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;</div>

<div style="font-size: 12.0px;font-family: standard;">And to the pom.xml we added following dependecies:</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;</div>

<div style="font-size: 12.0px;font-family: standard;">&lt;dependency&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;&lt;groupId&gt;org.keycloak&lt;/groupId&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;keycloak-jetty92-adapter&lt;/artifactId&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;1.8.1.Final&lt;/version&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&lt;/dependency&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&lt;dependency&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;&lt;groupId&gt;org.keycloak&lt;/groupId&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;keycloak-core&lt;/artifactId&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;1.8.1.Final&lt;/version&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&lt;/dependency&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&lt;dependency&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp; &nbsp;&lt;groupId&gt;org.keycloak&lt;/groupId&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;keycloak-services&lt;/artifactId&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;1.8.1.Final&lt;/version&gt;</div>

<div style="font-size: 12.0px;font-family: standard;">&lt;/dependency&gt;</div>
</div></div></body></html>