title: Hadoop Hive UDF with external library
body: <p>I'm trying to write a UDF for Hadoop Hive, that parses User Agents. Following code works fine on my local machine, but on Hadoop I'm getting:</p>
  
  <blockquote>
    <p>org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public java.lang.String MyUDF .evaluate(java.lang.String) throws org.apache.hadoop.hive.ql.metadata.HiveException on object MyUDF@64ca8bfb of class MyUDF with arguments {All Occupations:java.lang.String} of size 1',</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>import java.io.IOException;
  import org.apache.hadoop.hive.ql.exec.UDF;
  import org.apache.hadoop.hive.ql.metadata.HiveException;
  import org.apache.hadoop.io.Text;
  import org.apache.hadoop.*;
  import com.decibel.uasparser.OnlineUpdater;
  import com.decibel.uasparser.UASparser;
  import com.decibel.uasparser.UserAgentInfo;
  
  public class MyUDF extends UDF {
  
      public String evaluate(String i) {
          UASparser parser = null;         
          parser = new UASparser(); 
          String key = "";
          OnlineUpdater update = new OnlineUpdater(parser, key);
          UserAgentInfo info = null;
          info = parser.parse(i);
          return info.getDeviceType();
      }
  }
  </code></pre>
  
  <p>Facts that come to my mind I should mention:</p>
  
  <ul>
  <li><p>I'm compiling with Eclipse with "export runnable jar file" and extract required libraries into generated jar option </p></li>
  <li><p>I'm uploading this "fat jar" file with Hue</p></li>
  <li><p>Minimum working example I managed to run:</p>
  
  <p><code>public String evaluate(String i) {
  return "hello" + i.toString()";
  }</code></p></li>
  <li><p>I guess the problem lies somewhere around that library (downloaded from <a href="https://udger.com" rel="nofollow">https://udger.com</a>) I'm using, but I have no idea where.</p></li>
  </ul>
  
  <p>Any suggestions?</p>
  
  <p>Thanks, Michal</p>