Skip to content

Instantly share code, notes, and snippets.

@derms
Last active December 3, 2018 10:53
Show Gist options
  • Save derms/cd31a3d19db85315b1a400e7619abd52 to your computer and use it in GitHub Desktop.
Save derms/cd31a3d19db85315b1a400e7619abd52 to your computer and use it in GitHub Desktop.
Avoid java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. error for ml-gradle mlcp tasks

Example of how to avoid the error below when running mlcp tasks in windows

java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.
        at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:355)
        at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:370)
        at org.apache.hadoop.util.Shell.<clinit>(Shell.java:363)
        at org.apache.hadoop.util.GenericOptionsParser.preProcessForWindows(GenericOptionsParser.java:438)
        at org.apache.hadoop.util.GenericOptionsParser.parseGeneralOptions(GenericOptionsParser.java:484)
        at org.apache.hadoop.util.GenericOptionsParser.<init>(GenericOptionsParser.java:170)
        at org.apache.hadoop.util.GenericOptionsParser.<init>(GenericOptionsParser.java:153)
        at com.marklogic.contentpump.ContentPump.runCommand(ContentPump.java:111)
        at com.marklogic.contentpump.ContentPump.main(ContentPump.java:74)
  1. Create a dummy lib\bin\winutils.exe file in your project
  2. Define the ExtMlcpTask task class in your build.gradle that extends com.marklogic.gradle.task.MlcpTask
  3. Use the ExtMlcpTask task class when creating your mlcp tasks
plugins {
id 'com.marklogic.ml-gradle' version '3.10.0'
}
repositories {
mavenCentral()
jcenter()
maven { url "http://developer.marklogic.com/maven2/" }
}
configurations {
mlcp
}
dependencies {
mlcp "com.marklogic:mlcp:9.0.7"
mlcp files("lib")
}
class ExtMlcpTask extends com.marklogic.gradle.task.MlcpTask {
ExtMlcpTask() {
systemProperty("hadoop.home.dir","$project.rootDir/lib")
}
}
task myMlcpTask(type: ExtMlcpTask) {
classpath = configurations.mlcp
command = "IMPORT"
// put the rest of your mlcp config here
}
dummy file to avoid Could not locate executable null\bin\winutils.exe in the Hadoop binaries. error
# Root logger option
log4j.rootLogger=INFO, stdout
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment