hbase数据库的web小程序,web无法正常运行,无报错

我爱学习2hao 2017-05-02 09:16:55
代码在application中能直接运行,但是从web访问时就卡住不动,debug发现卡在 Result res=table.get(get);
实在是不会搞了,向各位前辈大神求助啊。。用的是Struts2做web框架
hbasedao2.java
package hbase.copy;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import news.news;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Result;
import org.apache.hadoop.hbase.util.Bytes;

import com.opensymphony.xwork2.config.Configuration;
public class hbasedao2 {
List<news> newslist=new ArrayList<news>();

public List<news> getNewslist() {
return newslist;
}
public void setNewslist(List<news> newslist) {
this.newslist = newslist;
}
public static org.apache.hadoop.conf.Configuration configuration;
public void getData(String tableName,String row,String columnFamily,String column) throws IOException{
configuration = (org.apache.hadoop.conf.Configuration) HBaseConfiguration.create();
((org.apache.hadoop.conf.Configuration) configuration).set("hbase.rootdir","hdfs://localhost:9000/hbase");
HTable table=new HTable(configuration,tableName);
Get get=new Get(Bytes.toBytes(row));
System.out.print(" 1");
org.apache.hadoop.hbase.client.Result result=table.get(get);
System.out.print(" 2");
byte[] rb=result.getValue(Bytes.toBytes(columnFamily),Bytes.toBytes(column));
System.out.print(" 3");
byte[] rb2=result.getRow();
if(rb==null||rb2==null)
return;
news news=new news();
String value=new String(rb,"utf-8");
String value2=new String(rb2,"utf-8");
news.setUrl(value);
news.setKey(value2);
newslist.add(news);
}

}

...全文
462 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
我爱学习2hao 2017-05-02
  • 打赏
  • 举报
回复
会不会是lib里jar包的问题,在引用jar包里全导入了hbase里的jar,在lib/下只有commons-codec-1.7.jar commons-collections-3.2.1.jar commons-configuration-1.6.jar commons-lang-2.6.jar commons-logging-1.1.3.jar guava-12.0.1.jar hadoop-auth-2.5.0.jar hadoop-common-2.5.0.jar hbase-client-0.98.8-hadoop2.jar hbase-common-0.98.8-hadoop2.jar hbase-protocol-0.98.8-hadoop2.jar htrace-core-2.04.jar jackson-core-asl-1.9.13.jar jackson-mapper-asl-1.9.13.jar log4j-1.2.17.jar netty-3.6.6.Final.jar protobuf-java-2.5.0.jar slf4j-api-1.7.5.jar slf4j-log4j12-1.7.5.jar zookeeper-3.4.6.jar

7,388

社区成员

发帖
与我相关
我的任务
社区描述
其他数据库开发 数据仓库
社区管理员
  • 数据仓库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧