title: Keycloak and JBoss: Edit location of config file keycloak.json
body: <p>I'm using JBoss EAP 6.2, JavaEE 6.0 and keycloak-eap6-adapter-dist 6.0.1 for authentication against Keycloak.</p>
  
  <p>The keycloak.json is currently packed in the deployed war archive (under WEB-INF), so it is not interchangeable for each customer.</p>
  
  <p>Do you know how to change the path of keycloak.json to a external path to make it interchangeable by each installation/stage (e.g. using Docker)?</p>
  
  <hr>
  
  <p>Solution: Thanks to ravthiru we implemented a custom config resolver like this:</p>
  
  <pre><code>public class CustomKeycloakResolver implements KeycloakConfigResolver {
  
      private KeycloakDeployment deployment;
  
      @Override
      public KeycloakDeployment resolve(OIDCHttpFacade.Request request) {
          if (deployment != null) {
              return deployment;
          }
  
          InputStream is;
          try {
              is = new FileInputStream(System.getenv("KEYCLOAK_CONFIG_FILE"));
          } catch (FileNotFoundException e) {
              throw new RuntimeException(e);
          }
          deployment = KeycloakDeploymentBuilder.build(is);
          return deployment;
      }
  }
  
  </code></pre>
  
  <p>and registered it in the <code>WEB-INF/web.xml</code> like this:</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;keycloak.config.resolver&lt;/param-name&gt;
      &lt;param-value&gt;my.package.CustomKeycloakResolver&lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>Now you can specify the path directly with an environment variable in your Docker-Container.</p>