AnsweredAssumed Answered

Hbase with Servlet and JSP

Question asked by samsalman on Jul 3, 2013
Latest reply on Jul 16, 2013 by nabeel
Hello Experts,

I am quite new to Hbase and Hadoop and above all new to java too. Recently started working on Hbase and Java. I have successfully installed & configured Hadoop & Hbase and also made my 1st ever java application on hbase using this tutorial
http://autofei.wordpress.com/2012/04/02/java-example-code-using-hbase-data-model-operations/

Now, I want to connect hbase with web application using servlet and Jsp. In this regard, I made one jsp page where I get users input and transfer them to servlet to insert them into my HTable, but unfortunately I am facing this error :

<pre>
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)

</pre>

I haven't done anything special just passed values from jps through parameters to Servlet and used addRecord function that mentioned in given link. Said error comes when I make instance of my HTable by this code:
<code>
HTable table = new HTable(conf, "scores");
</code>

I really don't know what to do as I couldn't find any tutorial to use Hbase with Servlet and Jsp. I request please guide me how to use Hbase with Servlet and Jsp and also kindly point out me any tutorial to use Hbase in web application as I have to develop a complete web application which will be my degree project.

Thanks in advance,

Regards,

Sam

Outcomes