When you specify -LIBJARS with the Hadoop jar command. First, make sure you edit your driver class as shown below:
public class myDriverClass extends Configured implements Tool { public static void main(String[] args) throws Exception { int res = ToolRunner.run(new Configuration(), new myDriverClass(), args); System.exit(res); } public int run(String[] args) throws Exception {
Now edit the hadoop jar command as shown below:
hasoop jar YourApplication.jar [myDriverClass] args -libjars path / to / jar / file
Now let's understand what happens below. We mainly process new command line arguments by implementing the TOOL interface . ToolRunner is used to run classes that implement the Tool interface. It works in conjunction with the GenericOptionsParser to parse the hadoop command line arguments and modify the configuration of the tool.
In our Main (), we call ToolRunner.run (new configuration (), new myDriverClass (), args) - this launches this tool Tool.run (String []), after parsing with the help of general arguments . It uses the given configuration or builds one if it is null, and then sets up the configuration of the tool with a possibly modified version of conf.
Now in the run method, when we call getConf (), we get a modified version of the Configuration. So make sure you have a line at the bottom of your code. If you implement the rest and still use the conf = new Configuration () configuration, nothing will work.
Configuration conf = getConf ();
Isaiah4110
source share