Cannot solve these errors Java (Pig UDF) adding libraries, org.apache

574 Views Asked by At
package com.mirox.weblog; //error here -The type    org.apache.commons.logging.Log cannot be resolved. It is indirectly referenced from required .class files

import java.io.IOException;
import java.text.SimpleDateFormat;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;

/* To convert date to hive usable format
*/
public class Date_udf extends EvalFunc{


public String exec(Tuple input)
{
    if(input == null || input.size() == 0)
        return null;
    String s = "";
    String p = "";
    try
    {
        if(input.get(0) != null) //error here in input.get(0) -The type org.apache.hadoop.io.WritableComparable cannot be resolved. It is indirectly referenced from required .class files
        {
            s = input.get(0).toString();
            SimpleDateFormat fromFormat = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss");//input date format
            SimpleDateFormat toFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//output date +format
            p = toFormat.format(fromFormat.parse(s));// converting date format
        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    return p;
}}

The project I am doing is Web-log analysis (attack detection )using Hadoop (pig, hive, scoop, oozie)

Tried adding libs in WEB/INF,added commons codec 1.10, commons fileupload 1.3.1, commons io 2.5, and all other libs that I could find.

I wasn't getting these errors before.

I'm a beginner a help/fix would be hugely appreciated.

1

There are 1 best solutions below

0
On

Add commons-logging jar in your classpath. It should fix the error.