Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8495679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:38:22+00:00 2026-06-10T23:38:22+00:00

I’m using spring data + hbase to write some values into a HBase database.

  • 0

I’m using spring data + hbase to write some values into a HBase database.
Unfortunately the HbaseTemplate seems to close the connection after the first call.

I’m new to Spring and HBase/Hadoop, so i don’t know if this is a Spring/HBase Configuration issue or another stupidity

Testclass:

package org.springframework.data.hadoop.samples;

import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.hadoop.hbase.HbaseTemplate;
import org.springframework.data.hadoop.hbase.TableCallback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/hbase-context.xml")
public class WordCountWorkflowTest {

    @Autowired
    private ApplicationContext ctx;

    @Autowired
    private HbaseTemplate hbaseTemplate;

    @Test
    public void testWorkflowNS() throws Exception {
        if (hbaseTemplate == null) {
            throw new NullPointerException("template null!");
        }
        // Write to HBase
        InnerTableCallback itc = new InnerTableCallback("JustaString", 42);
        hbaseTemplate.execute("Wordcount", itc);
        itc = new InnerTableCallback("Anotherstring", 23);
        // Here the HBase insert fails
        hbaseTemplate.execute("Wordcount", itc);
    }

    @Test
    public void testWorkflowNSSucess() throws Exception {
        System.out.println("done");
    }

    /**
     * This is a Inner class providing access to the HBase Table to store the
     * counted words and number of matches.
     * 
     * */
    class InnerTableCallback implements TableCallback<Object> {

        String foundStr;

        int no;

        /**
         * The constructor just saved the given foundStr/no tuple in inner
         * variables.
         * 
         * @param foundstr
         *            string found in the text
         * @param no
         *            number of found matches
         * @return null
         * */
        public InnerTableCallback(String foundStr, int no) {
            this.foundStr = foundStr;
            this.no = no;
        }

        /**
         * This Method puts the given String and number of found matches into
         * the HBase table the column family is "cf1" and the column is
         * "matches". The rowname is the found string.
         * */
        @Override
        public Object doInTable(HTable table) throws Throwable {
            Put p = new Put(Bytes.toBytes(foundStr));
            // Put operation on hbase shell:
            // hbase(main):005:0> put 'testtable', 'myrow-2', 'colfam1:q2',
            // 'value-2'
            // add(byte[] family, byte[] qualifier, byte[] value)
            p.add(Bytes.toBytes("cf1"), Bytes.toBytes("matches"),
                    Bytes.toBytes(new Integer(no).toString()));
            table.put(p);
            return null;
        }
    }
}

hbase-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:hdp="http://www.springframework.org/schema/hadoop"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">

    <context:property-placeholder location="classpath:batch.properties,classpath:hadoop.properties"
            ignore-resource-not-found="true" ignore-unresolvable="true" />

    <context:component-scan base-package="org.springframework.data.hadoop.samples" />

    <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>

    <bean id="hbaseTemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate" p:configuration-ref="hbaseConfiguration"/>

    <hdp:hbase-configuration>           
    </hdp:hbase-configuration>
</beans>

Stacktrace:

org.springframework.data.hadoop.hbase.HbaseSystemException: org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@61bb0cc0 closed; nested exception is java.io.IOException: org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@61bb0cc0 closed
    at org.springframework.data.hadoop.hbase.HbaseUtils.convertHbaseException(HbaseUtils.java:42)
    at org.springframework.data.hadoop.hbase.HbaseTemplate.convertHbaseAccessException(HbaseTemplate.java:111)
    at org.springframework.data.hadoop.hbase.HbaseTemplate.execute(HbaseTemplate.java:82)
    at org.springframework.data.hadoop.samples.WordCountWorkflowTest.testWorkflowNS(WordCountWorkflowTest.java:35)
    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:601)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    ....
Caused by: java.io.IOException: org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@61bb0cc0 closed
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:822)
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:810)
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.processBatchCallback(HConnectionManager.java:1492)
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.processBatch(HConnectionManager.java:1377)
    at org.apache.hadoop.hbase.client.HTable.flushCommits(HTable.java:916)
    at org.apache.hadoop.hbase.client.HTable.doPut(HTable.java:772)
    at org.apache.hadoop.hbase.client.HTable.put(HTable.java:747)
    at org.springframework.data.hadoop.samples.WordCountWorkflowTest$InnerTableCallback.doInTable(WordCountWorkflowTest.java:83)
    at org.springframework.data.hadoop.hbase.HbaseTemplate.execute(HbaseTemplate.java:72)

Cheers,R

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:38:24+00:00Added an answer on June 10, 2026 at 11:38 pm

    Solved!

    I’ve used a older and deprecated version of the spring-data-hadoop package (Milestone) in my maven pom.xml. I switched to the Snapshot repository, which fixes the incorrect handling of HBase tables.

    If you use spring-batch: I had to change the <tasklet> definitions for hadoop to <job-tasklet> in the *context.xml with the new version.

    The error message from the XML parser was:

    The matching wildcard is strict, but no declaration can be found for element 'tasklet'
    

    Hope this helps someone 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.