title: Tomcat-KeyCloak: FAIL -Deployed application at context path but context failed to start
body: <p>I'm trying to authenticate a Tomcat7 webapp (Server 1) using KeyCloak 4.0.0 (deployed on Server 2)</p>
  
  <p>I've followed the instructions listed <a href="https://www.keycloak.org/docs/3.3/securing_apps/topics/oidc/java/tomcat-adapter.html#_tomcat_adapter" rel="nofollow noreferrer">here</a>, but each time I try to develop a WAR on Tomcat (Server 1) I got this error:</p>
  
  <pre><code>FAIL - Deployed application at context path /my _path but context failed to start
  </code></pre>
  
  <p>corresponding to this Exception in Tomcat:</p>
  
  <pre><code>Apr 24, 2018 5:07:09 PM org.apache.catalina.core.StandardContext listenerStart
  SEVERE: Exception sending context initialized event to listener instance of class org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
  java.lang.RuntimeException: Unable to instantiate MessageBodyReader
      at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:760)
      at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:742)
      at org.jboss.resteasy.spi.ResteasyDeployment.registerProvider(ResteasyDeployment.java:505)
      at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:305)
      at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:225)
      at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:28)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
      at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:558)
      at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1747)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)
      at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)
      at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1516)
      at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:739)
      at org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java:457)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:653)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.RuntimeException: Illegal to inject a message body into a singleton into public org.codehaus.jackson.jaxrs.JacksonJsonProvider(org.codehaus.jackson.map.ObjectMapper,org.codehaus.jackson.jaxrs.Annotations[])
      at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:209)
      at org.jboss.resteasy.core.ConstructorInjectorImpl.injectableArguments(ConstructorInjectorImpl.java:63)
      at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:129)
      at org.jboss.resteasy.spi.ResteasyProviderFactory.getProviderInstance(ResteasyProviderFactory.java:1038)
      at org.jboss.resteasy.spi.ResteasyProviderFactory.addMessageBodyReader(ResteasyProviderFactory.java:478)
      at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:756)
      ... 49 more
  </code></pre>
  
  <p>Maybe my issue is somehow related to this <a href="https://stackoverflow.com/questions/49391338/cannot-get-keycloak-tomcat-7-adapter-to-work-version-3-4-3-final">one</a>.</p>
  
  <p>What's puzzles me is that such error does <strong>not</strong> seem to depend by my WAR application. No matters which WAR I  try to deploy on Tomcat, I always have this error, even if the WAR is NOT using KeyCloak. I mean: even if my WAR does not contain any "security-constraint" element nor "filter" nor "role-name", no other stuff regarding KeyCloak (i.e. all my pages are public), 
  I got always the FAIL error when deploying it.</p>
  
  <p>This seems related to the installation of the <em>keycloak-tomcat7-adapter-dist.zip</em> JARs into the Tomcat <em>lib</em> directory, as depicted <a href="https://www.keycloak.org/docs/3.3/securing_apps/topics/oidc/java/tomcat-adapter.html#_tomcat_adapter" rel="nofollow noreferrer">here</a>. If I just remove all these JARs from the <em>lib</em> folder, then I solve the problem (but of course in such scenario I can't use KeyCloak authentication).</p>
  
  <p>Am I missing something (maybe the WAR and KeyCloak must live in the same Tomcat server), or is there a bug in the Keycloak tomcat 7 adapter?</p>