Extend the Knox Gateway classpath

Learn how to extend the Knox Gateway classpath by prepending or appending custom paths to include additional JAR files or dependencies outside the Knox Gateway home directory.

  1. In Cloudera Manager, select the Knox service.
  2. Go to the Configuration tab.
  3. Search for Knox Service Advanced Configuration Snippet (Safety Valve) for conf/gateway-site.xml.
  4. To append new path(s) to the classpath, click the + icon and add the following property:
    • Name: gateway.server.append.classpath
    • Value: The path to your custom libraries, for example /new/append/path/*.jar

    The gateway.server.append.classpath property adds the specified paths to the end of the Knox Gateway classpath, allowing Knox to load additional libraries after the default ones.



  5. To prepend new path(s) to the classpath, click the + icon and add the following property:
    • Name: gateway.server.prepend.classpath
    • Value: The path to your custom libraries, for example /new/prepend/path/*.jar

    The gateway.server.prepend.classpath property adds the specified paths to the beginning of the Knox Gateway classpath, allowing your custom libraries to take precedence over the default Knox libraries.



  6. Configure the path value according to your requirements using the following syntax rules:
    • To include multiple locations, separate them with a comma (,) or semicolon (;).
    • Use *.jar to include all JAR files in a folder.
    • Use * to include all files in a folder.
    • Use /folder to include class files from folder hierarchies. For example, to include GatewayServer.class, place it in org/apache/knox/gateway.
  7. Click Save Changes(CTRL+S).
  8. Restart the Knox service to apply the classpath changes.

    Go to Actions > Restart and wait for the restart to complete.