最近在学习Linux下sqoop连接hbase数据库并导入数据时出现如下错误:

job: java.io.IOException: java.lang.reflect.InvocationTargetException
        at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(Con                                                                                        nectionFactory.java:240)
        at org.apache.hadoop.hbase.client.ConnectionManager.createConnection(Con                                                                                        nectionManager.java:410)
        at org.apache.hadoop.hbase.client.ConnectionManager.createConnection(Con                                                                                        nectionManager.java:403)
        at org.apache.hadoop.hbase.client.ConnectionManager.getConnectionInterna                                                                                        l(ConnectionManager.java:281)
        at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:202)
        at org.apache.sqoop.mapreduce.HBaseImportJob.jobSetup(HBaseImportJob.jav                                                                                        a:163)
        at org.apache.sqoop.mapreduce.ImportJobBase.runImport(ImportJobBase.java                                                                                        :264)
        at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:668)
        at org.apache.sqoop.manager.MySQLManager.importTable(MySQLManager.java:1                                                                                        18)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:497)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:605)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:236)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct                                                                                        orAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC                                                                                        onstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(Con                                                                                        nectionFactory.java:238)
        ... 16 more
Caused by: java.lang.NoClassDefFoundError: io/netty/channel/EventLoopGroup
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:274)
        at org.apache.hadoop.conf.Configuration.getClassByNameOrNull(Configurati                                                                                        on.java:2051)
        at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.jav                                                                                        a:2016)
        at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2110                                                                                        )
        at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2136                                                                                        )
        at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplement                                                                                        ation.<init>(ConnectionManager.java:631)
        ... 21 more
Caused by: java.lang.ClassNotFoundException: io.netty.channel.EventLoopGroup
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 28 more

这个错误,出现之后困扰了我很久首先第一个错误java.lang.reflect.InvocationTargetException,这是一个Java反射异常,开始我还以为是哪一点配置出现错误了,所以这个问题一直困扰了我好久,后来进过自己的一步步测试发现,这个错误根本不是什么配置的锅,而是添加在环境中的hbase-client-*.jar这个包的问题,出现这个问题可能是你的这个jar包与你系统上装的hbase和sqoop版本的问题

解决办法:把hbase-client-*.jar换个版本,换高版本还是低版本,根据你装hbase的来说


然后第二个问题: java.lang.ClassNotFoundException: io.netty.channel.EventLoopGroup,这个问题很明显是找不到这个类所导致的,而这个类是在netty-all.jar包下的

解决办法:想你的hbase和sqoop环境中添加netty-all-4.0.23.Final.jar这个包,根据你装的换版本,不过根据我的实验,好像在低版本中,不需要添加这个包。

上面这些希望对大家有帮助。。。

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐