启动Azkaban报错:java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.toImmutableMap

问题描述:

启动Azkaban报错:
java.lang.NoSuchMethodError:com.google.common.collect.ImmutableMap.toImmutableMap

解决方法:

从报错信息来看,是找不到toImmutableMap这个方法。首先找到类ImmutableMap对应的Jar包为guava,然后在服务器查找这个Jar包:

find / -name "guava*.jar"

发现除了Azkaban安装目录,其他程序目录下也有guava包。Azkaban里面的guava包版本为guava-21.0.jar,其他程序的版本有11,14,17,18,19,21,25,怀疑是由于有多个guava包,而使用的是低版本的包,里面没有toImmutableMap方法。

接下来,看看azkaban运行时候的classpath是什么样的。查看Web Server启动文件start-web.sh

more /u01/app/azkaban-3.50.0/azkaban-web-server-0.1.0-SNAPSHOT/bin/start-web.sh

内容为:

#!/bin/bash

script_dir=$(dirname $0)

${script_dir}/internal/internal-start-web.sh >webServerLog_`date +%F+%T`.out 2>&1 &

调用的是internal-start-web.sh,于是再查看:

more /u01/app/azkaban-3.50.0/azkaban-web-server-0.1.0-SNAPSHOT/bin/internal/internal-start-web.sh

内容为:

#!/bin/bash

azkaban_dir=$(dirname $0)/../..

# Specifies location of azkaban.properties, log4j.properties files
# Change if necessary
conf=$azkaban_dir/conf

if [[ -z "$tmpdir" ]]; then
tmpdir=/tmp
fi

for file in $azkaban_dir/lib/*.jar;
do
  CLASSPATH=$CLASSPATH:$file
done

for file in $azkaban_dir/extlib/*.jar;
do
  CLASSPATH=$CLASSPATH:$file
done

for file in $azkaban_dir/plugins/*/*.jar;
do
  CLASSPATH=$CLASSPATH:$file
done

if [ "$HADOOP_HOME" != "" ]; then
        echo "Using Hadoop from $HADOOP_HOME"
        CLASSPATH=$CLASSPATH:$HADOOP_HOME/conf:$HADOOP_HOME/*
        JAVA_LIB_PATH="-Djava.library.path=$HADOOP_HOME/lib/native/Linux-amd64-64"
else
        echo "Error: HADOOP_HOME is not set. Hadoop job types will not run properly."
fi

if [ "$HIVE_HOME" != "" ]; then
        echo "Using Hive from $HIVE_HOME"
        CLASSPATH=$CLASSPATH:$HIVE_HOME/conf:$HIVE_HOME/lib/*
fi

echo $azkaban_dir;
echo $CLASSPATH;

executorport=`cat $conf/azkaban.properties | grep executor.port | cut -d = -f 2`
serverpath=`pwd`

if [[ -z "$AZKABAN_OPTS" ]]; then
  AZKABAN_OPTS="-Xmx4G"
fi
# Set the log4j configuration file
if [ -f $conf/log4j.properties ]; then
  AZKABAN_OPTS="$AZKABAN_OPTS -Dlog4j.configuration=file:$conf/log4j.properties -Dlog4j.log.dir=$azkaban_dir/logs"
else
  echo "Exit with error: $conf/log4j.properties file doesn't exist."
  exit 1;
fi
AZKABAN_OPTS="$AZKABAN_OPTS -server -Dcom.sun.management.jmxremote -Djava.io.tmpdir=$tmpdir -Dexecutorport=$executorport -Dserverpat
h=$serverpath"

java $AZKABAN_OPTS $JAVA_LIB_PATH -cp $CLASSPATH azkaban.webapp.AzkabanWebServer -conf $conf [email protected] &

echo $! > $azkaban_dir/currentpid

可以看到,Azkaban安装目录的jar包是在原$CLASSPATH之后的,如下:

for file in $azkaban_dir/lib/*.jar;
do
  CLASSPATH=$CLASSPATH:$file
done

这样,其他目录下的guava包就会被先找到使用。好了,问题原因找到了,解决方法就很简单了,将CLASSPATH=$CLASSPATH:$file改为CLASSPATH=$file:$CLASSPATH,让Azkaban安装目录下的guava包先被找到使用。另外,Executor Server的启动文件/u01/app/azkaban-3.50.0/azkaban-exec-server-0.1.0-SNAPSHOT/bin/internal/internal-start-executor.sh也需要做同样修改。

修改完成后,再启动服务就正常了。(Executor Server和Web Server都需要重新启动)

完毕。

猜你喜欢

转载自blog.csdn.net/andyguan01_2/article/details/88353889
0条评论
添加一条新回复