Hbase与Servlet和JSP

时间:2013-07-03 12:42:48

标签: jsp servlets glassfish hbase

我是Hbase和Hadoop的新手,也是Java的新手。最近开始研究Hbase和Java。我已经成功安装了&配置Hadoop& Hbase还使用本教程在hbase上创建了我的第一个java应用程序 http://autofei.wordpress.com/2012/04/02/java-example-code-using-hbase-data-model-operations/

现在,我想使用servlet和Jsp将hbase与Web应用程序连接起来。在这方面,我创建了一个jsp页面,我获取用户输入并将它们传输到servlet以将它们插入到我的HTable中,但不幸的是我遇到了这个错误:

    `SEVERE:   java.util.NoSuchElementException 
    at java.util.HashMap$HashIterator.nextEntry(HashMap.java:897) 
    at java.util.HashMap$KeyIterator.next(HashMap.java:928) 
    at org.apache.hadoop.security.UserGroupInformation.<init>(UserGroupInformation.java:430) 
    at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:452) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.apache.hadoop.hbase.util.Methods.call(Methods.java:37) 
    at org.apache.hadoop.hbase.security.User.call(User.java:590) 
    at org.apache.hadoop.hbase.security.User.callStatic(User.java:580) 
    at org.apache.hadoop.hbase.security.User.access$400(User.java:51) 
    at org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:397) 
    at org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:392) 
    at org.apache.hadoop.hbase.security.User.getCurrent(User.java:140) 
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionKey.<init>(HConnectionManager.java:435) 
    at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:180) 
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:155) 
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:133) 
    at com.Hbase.Controller.HbaseServlet.addRecord(HbaseServlet.java:89) 
    at com.Hbase.Controller.HbaseServlet.processRequest(HbaseServlet.java:67) 
    at com.Hbase.Controller.HbaseServlet.doPost(HbaseServlet.java:159) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544) 
    at java.lang.Thread.run(Thread.java:724) 

我没有做任何特别的事情,只是将jps中的值通过参数传递给Servlet,并使用了给定链接中提到的addRecord函数。当我通过这段代码制作我的HTable实例时出现错误:HTable table = new HTable(conf,“scores”);

我真的不知道该怎么做,因为我找不到任何使用Hbase和Servlet和Jsp的教程。我请求指导我如何使用Hbase与Servlet和Jsp,并且还请指出我在Web应用程序中使用Hbase的任何教程,因为我必须开发一个完整的Web应用程序,这将是我的学位项目。

提前致谢,

问候,

山姆

1 个答案:

答案 0 :(得分:0)

所以,最后我弄清楚自己为什么遇到java.util.NoSuchElementException的问题,这只是因为glassfish服务器4.0。当我将我的glassfish服务器降级到3.2时,它就像一个魅力......

谢谢。