title: Scala UDF: java.lang.NoClassDefFoundError: scala/ScalaObject
body: <p>I am trying to use Scala for UDFs, but the Pig job is failing with the 
  error "java.lang.NoClassDefFoundError: scala/ScalaObject". What am I doing wrong?</p>
  
  <p>$ cat NonEmpty.scala</p>
  
  <pre><code>package nonempty
  
  import org.apache.pig.FilterFunc
  import org.apache.pig.data._
  
  class NonEmpty extends FilterFunc {
    def exec(input: Tuple) = {
      val s = input.get(0)
      s match {
      case a: String =&gt; !a.isEmpty 
      case _ =&gt; false
     }
    }
  }
  </code></pre>
  
  <p>$ cat ex3.pig</p>
  
  <pre><code>register ./nonempty.jar 
  register ./scala-library.jar;
  
  define NonEmpty nonempty.NonEmpty();
  
  raw = load 'excite-small.log' using PigStorage('\t') as (user: chararray, time:chararray, query: chararray);
  
  locations = filter raw by NonEmpty(query);
  </code></pre>
  
  <p>Build: </p>
  
  <pre><code>scalac -cp ~/pig-0.9.2/pig-0.9.2.jar NonEmpty.scala
  jar -cf nonempty.jar nonempty
  </code></pre>
  
  <p>Pig Stack Trace:</p>
  
  <pre><code>2 ---------------
  3 ERROR 2998: Unhandled internal error. scala/ScalaObject
  4 
  5 java.lang.NoClassDefFoundError: scala/ScalaObject
  (...)
  </code></pre>