title: Java App Engine - Validate JSON Schema with proper Library
body: <p>I'm looking for a valid JsonSchema validation library that could work with App Engine Java environment.</p>
  
  <p>I found 3 different libraries, but none of them is usable for different reasons.</p>
  
  <p><strong>Number 1: <a href="https://bintray.com/bintray/jcenter/org.kitchen-eel:json-schema-validator" rel="nofollow">json-schema-validator</a></strong></p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.kitchen-eel&lt;/groupId&gt;
      &lt;artifactId&gt;json-schema-validator&lt;/artifactId&gt;
      &lt;version&gt;1.5.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>And here is the code</p>
  
  <pre><code>ValidationReport report;
  JsonNode schema = JsonLoader.fromURL(Validator.class.getResource("schema.json"));
  JsonNode json = JsonLoader.fromString(input);
  
  JsonSchemaFactory factory = JsonSchemaFactory.defaultFactory();
  JsonSchema jsonSchema = factory.fromSchema(schema);
  
  report = jsonSchema.validate(json);
  
  if (!report.isSuccess()) {
      // throw error
  }
  </code></pre>
  
  <p><em>The problem</em>: 
  It uses an older version of Guava (Guava 13.0.1) that I cannot use because my main project uses the version 19 but more important, I use newer Guava methods that in version 13 did not exists yet</p>
  
  <pre><code>java.lang.NoSuchMethodError: com.google.common.collect.FluentIterable.toImmutableSet()Lcom/google/common/collect/ImmutableSet;
      at org.eel.kitchen.jsonschema.syntax.draftv4.DraftV4TypeSyntaxChecker.&lt;clinit&gt;(DraftV4TypeSyntaxChecker.java:43)
  </code></pre>
  
  <hr>
  
  <p><strong>Number 2: <a href="https://github.com/everit-org/json-schema" rel="nofollow">org.everit.json.schema</a></strong></p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.everit.json&lt;/groupId&gt;
      &lt;artifactId&gt;org.everit.json.schema&lt;/artifactId&gt;
      &lt;version&gt;1.3.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>And here is the code</p>
  
  <pre><code>try (InputStream inputStream =  Validator.class.getResourceAsStream("schema.json")) {
      JSONObject rawSchema = new JSONObject(new JSONTokener(inputStream));
      Schema schema = SchemaLoader.load(rawSchema);
      schema.validate(new JSONObject(input)); // throws a ValidationException if this object is invalid
  }
  </code></pre>
  
  <p><em>The problem</em>: this library is compiled only for Java 8, which is not available for App Engine environment</p>
  
  <pre><code>java.lang.UnsupportedClassVersionError: org/everit/json/schema/loader/SchemaLoader : Unsupported major.minor version 52.0
  </code></pre>
  
  <hr>
  
  <p><strong>Number 3: <a href="https://github.com/fge/json-schema-validator" rel="nofollow">json-schema-validator</a></strong></p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;com.github.fge&lt;/groupId&gt;
      &lt;artifactId&gt;json-schema-validator&lt;/artifactId&gt;
      &lt;version&gt;2.2.6&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>And here is the code</p>
  
  <pre><code>JsonNode schema = JsonLoader.fromURL(HelloAppEngine.class.getResource("schema.json"));
  JsonNode json = JsonLoader.fromURL(HelloAppEngine.class.getResource("json.json"));
  
  JsonSchema jsonSchema = JsonSchemaFactory.byDefault().getJsonSchema(schema);
  ProcessingReport report = jsonSchema.validate(json);
  
  if (!report.isSuccess()) {
      // throw error;
  }
  </code></pre>
  
  <p><em>The problem</em>: It seems that Jackson uses a multi-thread way to execute the code, which in App Engine is forbidden if not declared through GAE ThreadManager</p>
  
  <pre><code>java.io.IOException: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
  </code></pre>
  
  <p>I did not found other Java implementations for this library, and all my tries was unsuccessful. The only way I made working is the first solution using Guava 13 (I disabled my code, which use newer Guava functions, rewriting the functionality with custom code)</p>
  
  <p>And finally... the question: does anyone have alternative libraries to the one I already shown which might work with App Engine?
  If possible, I want avoid downloading the Java8 library and recompile it for 7 version or even update the first library Guava dependency.</p>