一个java.lang.NoSuchMethodError错误,求帮助

editorplus 工程师  2015-10-16 04:59:28
自己写的main方法正常运行(表videoinfo2已创建)


public class HBaseTest {

HBaseDataOperate hdo = new HBaseDataOperate();
HBaseInsert hbi = new HBaseInsert();

public static Configuration configuration;

// 初始化参数
static {
configuration = HBaseConfiguration.create();
configuration.set("hbase.zookeeper.property.clientPort", "2181");
configuration.set("hbase.zookeeper.quorum", "slave1,slave2,slave3,slave4,slave5");
configuration.set("hbase.master", "master:60000");
}

public static void main(String args[]) {

String tableName = "videoinfo2";
QueryAll(tableName);
// 查询

}
public static void QueryAll(String tableName) {
try {
HTable table = new HTable(configuration, tableName);
ResultScanner rs = table.getScanner(new Scan());
for (Result r : rs) {
System.out.println("获得到rowkey:" + new String(r.getRow()));
for (KeyValue keyValue : r.raw()) {
System.out.println("列:" + new String(keyValue.getFamily())
+ "====值:" + new String(keyValue.getValue()));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

在javawebweb工程中类似的代码

public class HBaseConnection {

public static Configuration configuration;
private static List<String> tableList;

//初始化参数
static {
configuration = HBaseConfiguration.create();
configuration.set("hbase.zookeeper.property.clientPort", "2181");
configuration.set("hbase.zookeeper.quorum", "slave1,slave2,slave3,slave4,slave5");
configuration.set("hbase.master", "master:60000");
}
public static ResultScanner QueryByColumns(String tableName,HashMap<String, String> ColumnNameValueHashMap,List<String> ColumnNameList) {
ResultScanner rs = null;
try {
System.out.println("11111:"+tableName+":11111");
org.apache.hadoop.hbase.client.HTable table = new org.apache.hadoop.hbase.client.HTable(configuration, "videoinfo2");
List<Filter> filters = new ArrayList<Filter>();
if (ColumnNameList != null && ColumnNameList.size()> 0){
for (String ColumnName : ColumnNameList) {
String ColumnValue=ColumnNameValueHashMap.get(ColumnName);
System.out.println("ColumnName:"+ColumnName);
System.out.println("ColumnValue:"+ColumnValue);
Filter filter = new SingleColumnValueFilter(Bytes
.toBytes(ColumnName), null, CompareOp.EQUAL, Bytes
.toBytes(ColumnValue));
filters.add(filter);
}
}
FilterList filterList1 = new FilterList(filters);
Scan scan = new Scan();
scan.setFilter(filterList1);
rs = table.getScanner(scan);

} catch (Exception e) {
e.printStackTrace();
}
return rs;
}
}

运行失败

2015-10-16 16:28:59 org.apache.catalina.core.ApplicationDispatcher invoke
严重: Servlet.service() for servlet jsp threw exception
java.lang.NoSuchMethodError: org.apache.commons.lang.ArrayUtils.addAll([Ljava/lang/Object;[Ljava/lang/Object;)[Ljava/lang/Object;
at org.apache.hadoop.hbase.HConstants.<clinit>(HConstants.java:717)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionKey.<clinit>(HConnectionManager.java:446)
at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:199)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:151)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:129)
at com.test.connection.HBaseConnection.QueryByColumns(HBaseConnection.java:544)
at com.test.biz.VideoListGrade.getResultScanner(VideoListGrade.java:66)
at com.test.biz.VideoListGrade.listAll(VideoListGrade.java:21)
at org.apache.jsp.sptxzsy_jsp._jspService(sptxzsy_jsp.java:283)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at com.test.servlet.getVideoListHbase.doGet(getVideoListHbase.java:54)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
2015-10-16 16:28:59 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet getVideoListHbase threw exception
java.lang.NoSuchMethodError: org.apache.commons.lang.ArrayUtils.addAll([Ljava/lang/Object;[Ljava/lang/Object;)[Ljava/lang/Object;
at org.apache.hadoop.hbase.HConstants.<clinit>(HConstants.java:717)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionKey.<clinit>(HConnectionManager.java:446)
at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:199)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:151)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:129)
at com.test.connection.HBaseConnection.QueryByColumns(HBaseConnection.java:544)
at com.test.biz.VideoListGrade.getResultScanner(VideoListGrade.java:66)
at com.test.biz.VideoListGrade.listAll(VideoListGrade.java:21)
at org.apache.jsp.sptxzsy_jsp._jspService(sptxzsy_jsp.java:283)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at com.test.servlet.getVideoListHbase.doGet(getVideoListHbase.java:54)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)

上网查下说要么没有这个方法,要不就是有多个同名方法,有冲突。工程中确实有两个。
一个hbase.jar中
一个rt.jar的
求解决办法。
...全文
318 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
小张程序员 2018-09-11
错误提示中NoSuchMethodError意思是你类中没有该方法,并且你也说有两个同名字的包,这两个包不能同时引入,然后这两个包一个一个换着来
回复
Code_Noting 2018-09-11
应该是你引用的jar错了
回复
MaltDust 2018-09-11
感谢博主!遇到了一样的异常报错,但是完全没头绪,知道是包冲突之后找到解决方法了。
回复
兔子托尼啊 2015-10-21
是不是引用错了jar包了吧.
回复
editorplus 2015-10-21
怎么连个说话的人都没有用
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-10-16 04:59
社区公告
暂无公告