{"record":{"id":"65497bf76d3c83cb","repo":"juicedata/juicefs","slug":"compression-codec-not-found","errorCode":null,"errorMessage":"Compression codec not found: ","messagePattern":"Compression codec not found: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdk/java/src/main/java/io/juicefs/bench/TestDFSIO.java","lineNumber":492,"sourceCode":"      buffer = ThreadLocal.withInitial(() -> new byte[bufferSize]);\n      try {\n        baseDir = conf.get(\"test.basedir\");\n        fs = new Path(baseDir).getFileSystem(conf);\n      } catch (IOException e) {\n        throw new RuntimeException(\"Cannot create file system.\", e);\n      }\n      randomBytes = conf.getBoolean(\"test.randomBytes\", false);\n\n      // grab compression\n      String compression = getConf().get(\"test.io.compression.class\", null);\n      Class<? extends CompressionCodec> codec;\n\n      // try to initialize codec\n      try {\n        codec = (compression == null) ? null :\n                Class.forName(compression).asSubclass(CompressionCodec.class);\n      } catch (Exception e) {\n        throw new RuntimeException(\"Compression codec not found: \", e);\n      }\n\n      if (codec != null) {\n        compressionCodec = (CompressionCodec)\n                ReflectionUtils.newInstance(codec, getConf());\n      }\n\n    }\n\n    Path getDataDir() {\n      return new Path(baseDir, \"io_data\");\n    }\n\n    @Override\n      // IOMapperBase\n    void collectStats(OutputCollector<Text, Text> output,\n                      String name,\n                      long execTime,","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/src/main/java/io/juicefs/bench/TestDFSIO.java#L474-L510","documentation":"TestDFSIO benchmark wraps any failure to instantiate the configured compression codec in a RuntimeException with the (unfortunately empty, due to string concatenation bug) message \"Compression codec not found: \". The code resolves the compression config value to a class via Class.forName and checks it is a CompressionCodec subclass; any exception (class not on classpath, wrong name, not a codec) triggers this.","triggerScenarios":"Running TestDFSIO with -compression set to a class name that does not exist on the classpath, is misspelled, or is not a CompressionCodec subclass; configure() is called during localRun setup.","commonSituations":"Typo in codec class name (e.g. org.apache.hadoop.io.compress.GzipCompressor vs GzipCodec); missing jar on Hadoop classpath; using a codec name string like 'gzip' instead of a fully-qualified class name (this code requires FQCN, unlike core-site io.compression.codecs).","solutions":["Use the fully-qualified class name, e.g. org.apache.hadoop.io.compress.GzipCodec, in the -compression argument","Verify the codec jar is on the classpath (HADOOP_CLASSPATH or lib dir)","Omit the -compression option to disable compression (codec = null)","Add the codec to io.compression.codecs and verify with `hadoop jar ...` before benchmarking"],"exampleFix":"// before\ncompression = \"gzip\"\n// after\ncompression = \"org.apache.hadoop.io.compress.GzipCodec\"","handlingStrategy":"validation","validationCode":"try {\n  Class<?> cls = Class.forName(compression);\n  if (!CompressionCodec.class.isAssignableFrom(cls))\n    throw new IllegalArgumentException(compression + \" is not a CompressionCodec\");\n} catch (ClassNotFoundException e) {\n  throw new IllegalArgumentException(\"Codec not on classpath: \" + compression, e);\n}","typeGuard":"static boolean isValidCodec(String name, Configuration conf) {\n  try {\n    Class<?> c = Class.forName(name);\n    return CompressionCodec.class.isAssignableFrom(c);\n  } catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n  runBenchmark(conf);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Compression codec not found\")) {\n    LOG.error(\"Fix -compression: must be FQCN of a CompressionCodec on the classpath\");\n  } else throw e;\n}","preventionTips":["Always pass fully-qualified codec class names","Verify codec jars are on HADOOP_CLASSPATH in all nodes","Smoke-test the codec with a small job before full benchmark"],"tags":["hadoop","java","classpath","reflection"],"backgroundTag":"class-not-found","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}