scala udf:java.lang.noclassdeffounderror:scala/scalaobject

zazmityj  于 2021-06-24  发布在  Pig
关注(0)|答案(1)|浏览(335)

我正在尝试将scala用于UDF,但pig作业失败,出现错误“java.lang.noclassdeffounderror:scala/scalaobject”。我做错什么了?
$cat非空.scala

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 => !a.isEmpty 
    case _ => false
   }
  }
}

$cat ex3.1Pig

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);

内部版本:

scalac -cp ~/pig-0.9.2/pig-0.9.2.jar NonEmpty.scala
jar -cf nonempty.jar nonempty

清管器堆栈跟踪:

2 ---------------
3 ERROR 2998: Unhandled internal error. scala/ScalaObject
4 
5 java.lang.NoClassDefFoundError: scala/ScalaObject
(...)
hsgswve4

hsgswve41#

ScalaObject 位于 scala-library.jar 它需要包含在运行时类路径中。所以加上 scala-library.jar 运行程序的命令的运行时类路径。

相关问题