[keycloak-user] Keycloak and Tomcat 8 deserialize cors-allowed-methods

Bill Burke bburke at redhat.com
Sat Feb 21 10:11:13 EST 2015


Ugh, documentation is wrong on adapter config file.  Sorry it should be:

"cors-allowed-methods": "POST, PUT, DELETE"

not an array of strings.  Basically this is the value that is put in the 
cors header



On 2/21/2015 10:00 AM, Christopher Wallace wrote:
> Keycloak Users,
>
> I am attempting to configure Keycloak with Tomcat 8 and have deployed
> the following:
>
> /WEB-INF/web.xml
> <web-app xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/
> xml/ns/javaee/web-app_3_0.xsd"
> version="3.0">
> <module-name>customer-portal</module-name>
> <security-constraint>
> <web-resource-collection>
> <web-resource-name>mprworktrac</web-resource-name>
> <url-pattern>/mprworktrac</url-pattern>
> </web-resource-collection>
> <auth-constraint>
> <role-name>user</role-name>
> </auth-constraint>
> </security-constraint>
> <security-constraint>
> <web-resource-collection>
> <url-pattern>/mprworktrac</url-pattern>
> </web-resource-collection>
> <user-data-constraint>
> <transport-guarantee>CONFIDENTIAL</transport-guarantee>
> </user-data-constraint>
> </security-constraint>
> <login-config>
> <auth-method>BASIC</auth-method>
> <realm-name>this is ignored currently</realm-name>
> </login-config>
> <security-role>
> <role-name>admin</role-name>
> </security-role>
> <security-role>
> <role-name>user</role-name>
> </security-role>
> </web-app>
>
> /META-INF/content.xml
> <Context path="/mprworktrac">
> <Valve className="org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve"/>
> </Context>
>
>
> /WEB-INF/keyloak.json
> {
> "realm" : "worktrac",
> "resource" : "customer-portal",
> "realm-public-key" : "MIGfMA0GCSqGSIb3D...31LwIDAQAB",
> "auth-server-url" : "https://localhost:8443/auth",
> "ssl-required" : "external",
> "use-resource-role-mappings" : false,
> "enable-cors" : true,
> "cors-max-age" : 1000,
> "cors-allowed-methods" : [ "POST", "PUT", "DELETE", "GET" ],
> "bearer-only" : false,
> "expose-token" : true,
> "credentials" : {
> "secret" : "234234-234234-234234"
> },
> "connection-pool-size" : 20,
> "disable-trust-manager": false,
> "allow-any-hostname" : false,
> "truststore" :
> "/opt/keycloak-appliance-dist-all-1.1.0.Final/keycloak/standalone/configuration/secret.jks",
> "truststore-password" : "secret",
> "client-keystore" :
> "/opt/keycloak-appliance-dist-all-1.1.0.Final/keycloak/standalone/configuration/secret.jks",
> "client-keystore-password" : "secret",
> "client-key-password" : "secret"
> }
>
> Extracted keycloak-tomcat8-adapter-dist-1.1.0.Final.zip to
> $CATALINA_HOME/lib
>
> I receive the following in catalina.out on startup:
> java.lang.RuntimeException:
> org.codehaus.jackson.map.JsonMappingException: Can not deserialize
> instance of java.lang.String out of START_ARRAY token
>   at [Source: java.io.FileInputStream at 7ff0e2e8; line: 9, column: 22]
> (through reference chain:
> org.keycloak.representations.adapters.config.AdapterConfig["cors-allowed-methods"])
>      at
> org.keycloak.adapters.KeycloakDeploymentBuilder.loadAdapterConfig(KeycloakDeploymentBuilder.java:104)
>      at
> org.keycloak.adapters.KeycloakDeploymentBuilder.build(KeycloakDeploymentBuilder.java:93)
>      at
> org.keycloak.adapters.tomcat.AbstractKeycloakAuthenticatorValve.keycloakInit(AbstractKeycloakAuthenticatorValve.java:116)
>      at
> org.keycloak.adapters.tomcat.AbstractKeycloakAuthenticatorValve.lifecycleEvent(AbstractKeycloakAuthenticatorValve.java:65)
>      at
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
>      at
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>      at
> org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
>      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:168)
>      at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
>      at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
>      at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
>      at
> org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1069)
>      at
> org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1719)
>      at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>      at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>      at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>      at java.lang.Thread.run(Thread.java:745)
> Caused by: org.codehaus.jackson.map.JsonMappingException: Can not
> deserialize instance of java.lang.String out of START_ARRAY token
>   at [Source: java.io.FileInputStream at 7ff0e2e8; line: 9, column: 22]
> (through reference chain:
> org.keycloak.representations.adapters.config.AdapterConfig["cors-allowed-methods"])
>      at
> org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
>      at
> org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:219)
>      at
> org.codehaus.jackson.map.deser.std.StringDeserializer.deserialize(StringDeserializer.java:44)
>      at
> org.codehaus.jackson.map.deser.std.StringDeserializer.deserialize(StringDeserializer.java:13)
>      at
> org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
>      at
> org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
>      at
> org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
>      at
> org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
>      at
> org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
>      at
> org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1909)
>      at
> org.keycloak.adapters.KeycloakDeploymentBuilder.loadAdapterConfig(KeycloakDeploymentBuilder.java:102)
>      ... 17 more
>
> Your help is greatly appreciated as I am excited to get this working :-)
>
> --
> Chris Wallace
> cjwallac at gmail.com <mailto:cjwallac at gmail.com>
>
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com


More information about the keycloak-user mailing list