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

2022-10-07,,,,

问题描述:

启动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 $@ &

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都需要重新启动)

完毕。

到此这篇关于启动azkaban报错:java.lang.nosuchmethoderror: com.google.common.collect.immutablemap.toimmutablemap的文章就介绍到这了,更多相关启动azkaban报错内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

《解决启动Azkaban报错问题:java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.toImmutableMap.doc》

下载本文的Word格式文档,以方便收藏与打印。