diff --git a/java/src/main/java/com/mapd/parser/server/CalciteDirect.java b/java/src/main/java/com/mapd/parser/server/CalciteDirect.java
index <HASH>..<HASH> 100644
--- a/java/src/main/java/com/mapd/parser/server/CalciteDirect.java
+++ b/java/src/main/java/com/mapd/parser/server/CalciteDirect.java
@@ -127,6 +127,10 @@ final static Logger MAPDLOGGER = LoggerFactory.getLogger(CalciteDirect.class);
     }
     String relAlgebra;
     try {
+      if (Thread.currentThread().getContextClassLoader() == null) {
+        ClassLoader cl = ClassLoader.getSystemClassLoader();
+        Thread.currentThread().setContextClassLoader(cl);
+      }
       relAlgebra = parser.getRelAlgebra(sqlText, legacySyntax, mapDUser);
       MAPDLOGGER.debug("After get relalgebra");
     } catch (SqlParseException ex) {
Set context class loader in CalciteDirect

Calcite needs it when running through JNI when serializing RexSubQuery nodes
because of Janino.