Including external jars in a Hadoop job

Labels: , , ,

One of the disadvantages of setting up a Hadoop development environment in Eclipse is that I have been dependent on Eclipse to take care of job submission for me and so I had never worried about doing it by hand. I have been developing mostly on a single node cluster (i.e my laptop) which meant I never had the need to submit a job to an actual cluster, a remote cluster in this case. Also, the first MapReduce programs I have written and run on the cluster (more to follow) were not dependent on third party jars. However, the program I am working on depends on a third-party xml parser which in turn depends on another jar.

As it turns out, I had to specify 3 external jars everytime I submit a job. I knew there was a -libjars option that you could use as I had seen it somewhere (including the hadoop help when you don't specify all arguments for a command) but I did not pay attention since I did not need it then. Googling around, I found a mention of copying the jars to the lib folder of the Hadoop installation. It seemed a good solution untill you think about a multi-node cluster which means you have to copy the libraries to every node. Also, what if you do not have complete control of the clusters. Will you have write permissions to lib folder.

Luckily, I bumped into a solution suggested Doug Cutting as an answer to someone who had a similar predicament. The solution was to create a "lib" folder in your project and copy all the external jars into this folder. According to Doug, Hadoop will look for third-party jars in this folder. It works great!

1 comments:
gravatar
Xuefu said...
December 4, 2009 5:15 PM  

I tried the solutions mentioned in the blog. However, only the second solution worked for me. The better one, which the author suggested, didn't work for me, unfortunately, even though the same approach was proposed by amazon. Thus, I'm wondering how that solution works exactly. For me, I created a jar file, which contains my code as well as a lib directory with 3rd party jars in it. Any insight is greatly appreciated.

Post a Comment

Hadoop and Distributed Computing at Yahoo!

My Blog List