2013-01-02 2 views
0

UDF 용 스칼라를 사용하려고했지만 "% 2!"클래스 오류가있는 돼지 작업이 실패했습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? 스칼라 UDF : java.lang.NoClassDefFoundError : scala/ScalaObject

ex3.pig $ 고양이 NonEmpty.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 
    } 
    } 
} 

$ 고양이

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 
(...) 

답변

5

ScalaObject은 런타임 클래스 경로에 포함되어야하는 scala-library.jar에 있습니다. 따라서 프로그램을 실행중인 명령의 런타임 클래스 경로에 scala-library.jar을 추가하십시오.