Index: occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/OccurrenceKeyIteratorTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/OccurrenceKeyIteratorTest.java	(revision 1977)
+++ occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/OccurrenceKeyIteratorTest.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.persistence;
 
+import org.apache.hadoop.hbase.client.*;
 import org.gbif.occurrencestore.common.model.constants.FieldName;
 
 import java.io.IOException;
@@ -7,10 +8,6 @@
 import java.util.UUID;
 
 import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.filter.CompareFilter;
 import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -40,7 +37,7 @@
   private HTablePool tablePool = null;
 
   @AfterClass
-  public static void afterClass() throws IOException {
+  public static void afterClass() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
   }
 
@@ -56,7 +53,7 @@
 
     tablePool = new HTablePool(TEST_UTIL.getConfiguration(), 1);
 
-    HTable table = (HTable) tablePool.getTable(TABLE_NAME);
+    HTableInterface table = tablePool.getTable(TABLE_NAME);
     int keyCount = 0;
     for (int i = 0; i < ID_1_COUNT; i++) {
       keyCount++;
Index: occurrence-search/src/test/java/org/gbif/occurrencestore/search/writers/HBaseOccurrenceWriter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-search/src/test/java/org/gbif/occurrencestore/search/writers/HBaseOccurrenceWriter.java	(revision 1977)
+++ occurrence-search/src/test/java/org/gbif/occurrencestore/search/writers/HBaseOccurrenceWriter.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.search.writers;
 
+import org.apache.hadoop.hbase.client.HTableInterface;
 import org.gbif.api.model.occurrence.Occurrence;
 import org.gbif.occurrencestore.common.model.constants.FieldName;
 import org.gbif.occurrencestore.persistence.HBaseFieldUtil;
@@ -20,7 +21,7 @@
 
 
   // HBase table
-  private final HTable hTable;
+  private final HTableInterface hTable;
 
   // Column family
   private final static byte[] CF = Bytes.toBytes(HBaseTableConstants.OCCURRENCE_COLUMN_FAMILY);
@@ -31,7 +32,7 @@
   /**
    * Default constructor.
    */
-  public HBaseOccurrenceWriter(HTable hTable) {
+  public HBaseOccurrenceWriter(HTableInterface hTable) {
     this.hTable = hTable;
   }
 
Index: pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- pom.xml	(revision 1978)
+++ pom.xml	(revision )
@@ -36,13 +36,13 @@
     <amqp.version>2.8.7</amqp.version>
     <!-- Fixing to the version JUnit and Mockito are depending on -->
     <aopalliance.version>1.0</aopalliance.version>
-    <bval.version>0.4</bval.version>
+    <bval.version>0.5</bval.version>
     <commons-beanutils.version>1.8.3</commons-beanutils.version>
     <commons-codec.version>1.6</commons-codec.version>
     <commons-digester.version>2.1</commons-digester.version>
     <commons-io.version>2.3</commons-io.version>
     <commmons-lang.version>3.1</commmons-lang.version>
-    <curator.version>1.0.20</curator.version>
+    <curator.version>1.3.3</curator.version>
     <dbunit.version>2.4.8</dbunit.version>
     <dwc-api.version>1.3</dwc-api.version>
     <dwca-reader.version>1.14</dwca-reader.version>
@@ -57,15 +57,18 @@
     <gbif-postal-service.version>0.4-SNAPSHOT</gbif-postal-service.version>
     <grizzly-servlet-webserver.version>1.9.50</grizzly-servlet-webserver.version>
     <!-- guava limited to 12 because of cdh3 hbase -->
-    <guava.version>12.0</guava.version>
+    <guava.version>14.0.1</guava.version>
     <guice.version>3.0</guice.version>
-    <hadoop.version>0.20.2-cdh3u3</hadoop.version>
+    <hadoop.version>2.0.0-mr1-cdh4.2.0</hadoop.version>
+    <hadoop-common.version>2.0.0-cdh4.2.0</hadoop-common.version>
+    <hadoop-hdfs.version>2.0.0-cdh4.2.0</hadoop-hdfs.version>
     <hamcrest.version>1.3</hamcrest.version>
-    <hbase.version>0.90.4-cdh3u3</hbase.version>
+    <hbase.version>0.94.2-cdh4.2.0</hbase.version>
     <hbase-utils.version>0.3</hbase-utils.version>
     <javax-validation-api.version>1.0.0.GA</javax-validation-api.version>
     <!-- Only update Jackson together with Jersey so that Jackson is the same version as the one used by Jersey -->
-    <jackson.version>1.9.7</jackson.version>
+    <!-- DaveMartin - cant see a dependency between jersey and jackson. Has it been removed -->
+    <jackson.version>1.9.9</jackson.version>
     <jcommander.version>1.30-gbif-20121018</jcommander.version>
     <!-- Only update Jackson together with Jersey so that Jackson is the same version as the one used by Jersey -->
     <jersey.version>1.12</jersey.version>
@@ -73,18 +76,18 @@
     <jersey-test-framework-core.version>1.12</jersey-test-framework-core.version>
     <junit.version>4.11</junit.version>
     <!-- fix logging to same as HBase to avoid conflicts with slf4j 1.6+ -->
-    <logback.version>0.9.17</logback.version>
+    <logback.version>0.9.29</logback.version>
     <mockito.version>1.9.0</mockito.version>
     <powermock-mockito.version>1.4.12</powermock-mockito.version>
     <registry-client.version>0.4</registry-client.version>
     <servlet-api.version>2.5</servlet-api.version>
     <!-- fix logging to same as HBase to avoid conflicts with slf4j 1.6+ -->
-    <slf4j.version>1.5.8</slf4j.version>
+    <slf4j.version>1.6.1</slf4j.version>
     <!--Solr/Lucene projects use the same versioning -->
     <solr-lucene.version>4.1.0</solr-lucene.version>
     <validation-api.version>1.0.0.GA</validation-api.version>
     <yammer.version>2.2.0</yammer.version>
-    <zookeeper.version>3.3.4-cdh3u3</zookeeper.version>
+    <zookeeper.version>3.4.5-cdh4.2.0</zookeeper.version>
   </properties>
 
   <scm>
@@ -406,6 +409,26 @@
       <dependency>
         <groupId>org.apache.hadoop</groupId>
         <artifactId>hadoop-core</artifactId>
+        <version>${hadoop.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hadoop</groupId>
+        <artifactId>hadoop-common</artifactId>
+        <version>${hadoop-common.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hadoop</groupId>
+        <artifactId>hadoop-hdfs</artifactId>
+        <version>${hadoop-hdfs.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hadoop</groupId>
+        <artifactId>hadoop-minicluster</artifactId>
+        <version>${hadoop.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hadoop</groupId>
+        <artifactId>hadoop-core-test</artifactId>
         <version>${hadoop.version}</version>
       </dependency>
       <dependency>
Index: occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/FragmentPersistenceServiceImplTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/FragmentPersistenceServiceImplTest.java	(revision 1977)
+++ occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/FragmentPersistenceServiceImplTest.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.persistence;
 
+import org.apache.hadoop.hbase.client.HTableInterface;
 import org.gbif.api.vocabulary.OccurrenceSchemaType;
 import org.gbif.occurrencestore.common.model.HolyTriplet;
 import org.gbif.occurrencestore.common.model.PublisherProvidedUniqueIdentifier;
@@ -107,7 +108,7 @@
   }
 
   @AfterClass
-  public static void afterClass() throws IOException {
+  public static void afterClass() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
     CURATOR.close();
     ZOOKEEPER_SERVER.stop();
@@ -142,7 +143,7 @@
 
     fragmentService = new FragmentPersistenceServiceImpl(TABLE_NAME, tablePool, occurrenceKeyService);
 
-    HTable table = (HTable) tablePool.getTable(TABLE_NAME);
+    HTableInterface table = tablePool.getTable(TABLE_NAME);
     Put put = new Put(Bytes.toBytes(xmlKey));
     put.add(CF, Bytes.toBytes(HBaseFieldUtil.getHBaseColumn(FieldName.CATALOG_NUMBER).getColumnName()),
       Bytes.toBytes(CAT));
Index: occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/keygen/AbstractHBaseKeyPersistenceService.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/keygen/AbstractHBaseKeyPersistenceService.java	(revision 1977)
+++ occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/keygen/AbstractHBaseKeyPersistenceService.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.persistence.keygen;
 
+import org.apache.hadoop.hbase.client.*;
 import org.gbif.api.exception.ServiceUnavailableException;
 import org.gbif.occurrencestore.common.model.constants.FieldName;
 import org.gbif.occurrencestore.persistence.HBaseFieldUtil;
@@ -15,18 +16,14 @@
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.filter.CompareFilter;
 import org.apache.hadoop.hbase.filter.Filter;
 import org.apache.hadoop.hbase.filter.FilterList;
 import org.apache.hadoop.hbase.filter.PrefixFilter;
 import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -36,6 +33,7 @@
  */
 public abstract class AbstractHBaseKeyPersistenceService implements KeyPersistenceService<Integer> {
 
+  private static final Logger LOG = LoggerFactory.getLogger(HBaseStore.class);
   private final HTablePool tablePool;
   private final String lookupTableName;
   private final HBaseStore<Integer> occurrenceTableStore;
@@ -141,7 +139,7 @@
     filters.add(valueFilter);
     FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL, filters);
     scan.setFilter(filterList);
-    HTable lookupTable = (HTable) tablePool.getTable(lookupTableName);
+    HTableInterface lookupTable = tablePool.getTable(lookupTableName);
     List<Delete> keysToDelete = Lists.newArrayList();
     try {
       ResultScanner resultScanner = lookupTable.getScanner(scan);
@@ -155,7 +153,13 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Failure accessing HBase", e);
     } finally {
+      if (lookupTable != null){
+          try {
-      tablePool.putTable(lookupTable);
+            tablePool.putTable(lookupTable);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
+          }
+      }
     }
   }
 
Index: occurrence-search/src/test/java/org/gbif/occurrencestore/search/OccurrenceSearchTestIT.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-search/src/test/java/org/gbif/occurrencestore/search/OccurrenceSearchTestIT.java	(revision 1977)
+++ occurrence-search/src/test/java/org/gbif/occurrencestore/search/OccurrenceSearchTestIT.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.search;
 
+import org.apache.hadoop.hbase.client.HTableInterface;
 import org.gbif.api.model.common.search.SearchResponse;
 import org.gbif.api.model.occurrence.Occurrence;
 import org.gbif.api.model.occurrence.search.OccurrenceSearchParameter;
@@ -109,7 +110,7 @@
   private static final Logger LOG = LoggerFactory.getLogger(OccurrenceSearchTestIT.class);
 
   @AfterClass
-  public static void afterClass() throws IOException {
+  public static void afterClass() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
     solrServer.shutdown();
   }
@@ -163,7 +164,7 @@
    * Loads test data from the CSV file and store it into Solr and HBase.
    */
   private static void loadOccurrences() {
-    final HTable hTable = (HTable) hTablePool.getTable(OCCURRENCE_TABLE);
+    final HTableInterface hTable = hTablePool.getTable(OCCURRENCE_TABLE);
     try {
       OccurrenceDataLoader.processOccurrences(CSV_TEST_FILE, new HBaseOccurrenceWriter(hTable),
         new SolrOccurrenceWriter(
@@ -172,7 +173,11 @@
       LOG.error("Error processing occurrence objects from file", e);
     } finally {
       commitToSolrQuietly();
+      try {
-      hTablePool.putTable(hTable);
+        hTablePool.putTable(hTable);
+      } catch (Exception e) {
+        LOG.error(e.getMessage(), e);
+      }
     }
   }
 
Index: occurrence-search/pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-search/pom.xml	(revision 1977)
+++ occurrence-search/pom.xml	(revision )
@@ -147,10 +147,20 @@
     <!-- false positive from dep:analyze - needed by hbaseminicluster -->
     <dependency>
       <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-hdfs</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-test</artifactId>
       <scope>test</scope>
     </dependency>
-    
+    <!-- Required for MiniDFSCluster after CDH4 upgrade -->
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-minicluster</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>net.sf.supercsv</groupId>
       <artifactId>super-csv</artifactId>
Index: occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/OccurrenceKeyPersistenceServiceImplTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/OccurrenceKeyPersistenceServiceImplTest.java	(revision 1977)
+++ occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/OccurrenceKeyPersistenceServiceImplTest.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.persistence;
 
+import org.apache.hadoop.hbase.client.HTableInterface;
 import org.gbif.occurrencestore.common.model.HolyTriplet;
 import org.gbif.occurrencestore.common.model.PublisherProvidedUniqueIdentifier;
 import org.gbif.occurrencestore.common.model.UniqueIdentifier;
@@ -94,7 +95,7 @@
   }
 
   @AfterClass
-  public static void afterClass() throws IOException {
+  public static void afterClass() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
     CURATOR.close();
     ZOOKEEPER_SERVER.stop();
@@ -111,7 +112,7 @@
       OCCURRENCE_TABLE_NAME, tablePool, ZOO_LOCK_PROVIDER);
     occurrenceKeyService =
       new OccurrenceKeyPersistenceServiceImpl(keyPersistenceService);
-    HTable lookupTable = (HTable) tablePool.getTable(LOOKUP_TABLE_NAME);
+    HTableInterface lookupTable = tablePool.getTable(LOOKUP_TABLE_NAME);
     Put put = new Put(Bytes.toBytes(TRIPLET_KEY));
     put.add(CF, Bytes.toBytes(HBaseTableConstants.LOOKUP_KEY_COLUMN), Bytes.toBytes(1));
     lookupTable.put(put);
@@ -121,7 +122,7 @@
     lookupTable.flushCommits();
     tablePool.putTable(lookupTable);
 
-    HTable counterTable = (HTable) tablePool.getTable(COUNTER_TABLE_NAME);
+    HTableInterface counterTable = tablePool.getTable(COUNTER_TABLE_NAME);
     put = new Put(Bytes.toBytes(HBaseTableConstants.COUNTER_ROW));
     put.add(Bytes.toBytes(HBaseTableConstants.COUNTER_COLUMN_FAMILY), Bytes.toBytes(HBaseTableConstants.COUNTER_COLUMN),
       Bytes.toBytes(Long.valueOf(2)));
Index: occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/keygen/HBaseLockingKeyServiceTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/keygen/HBaseLockingKeyServiceTest.java	(revision 1977)
+++ occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/keygen/HBaseLockingKeyServiceTest.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.persistence.keygen;
 
+import org.apache.hadoop.hbase.client.HTableInterface;
 import org.gbif.occurrencestore.persistence.api.KeyLookupResult;
 import org.gbif.occurrencestore.persistence.constants.HBaseTableConstants;
 
@@ -72,7 +73,7 @@
   }
 
   @AfterClass
-  public static void afterClass() throws IOException {
+  public static void afterClass() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
   }
 
@@ -121,7 +122,7 @@
   @Test
   public void testLockWriteDie() throws IOException {
     // setup: 2 rows, each one gets as far as writing the new id but "dies" before releasing lock
-    HTable lookupTable = (HTable) tablePool.getTable(LOOKUP_TABLE);
+    HTableInterface lookupTable = tablePool.getTable(LOOKUP_TABLE);
     String datasetKey = UUID.randomUUID().toString();
 
     byte[] lock1 = Bytes.toBytes(UUID.randomUUID().toString());
@@ -152,7 +153,7 @@
   @Test
   public void testConflictingIds() throws IOException {
     // setup: 2 rows with different lookupkeys and assigned ids
-    HTable lookupTable = (HTable) tablePool.getTable(LOOKUP_TABLE);
+    HTableInterface lookupTable = tablePool.getTable(LOOKUP_TABLE);
     String datasetKey = "fakeuuid";
 
     byte[] lookupKey1 = Bytes.toBytes(datasetKey + "|ABCD");
@@ -191,7 +192,7 @@
     Put put = new Put(lookupKey);
     put.add(Bytes.toBytes(HBaseTableConstants.LOOKUP_COLUMN_FAMILY),
       Bytes.toBytes(HBaseTableConstants.LOOKUP_LOCK_COLUMN), 0, lock);
-    HTable lookupTable = (HTable) tablePool.getTable(LOOKUP_TABLE);
+    HTableInterface lookupTable = tablePool.getTable(LOOKUP_TABLE);
     lookupTable.put(put);
     lookupTable.flushCommits();
     tablePool.putTable(lookupTable);
@@ -212,7 +213,7 @@
     Put put = new Put(lookupKey);
     put.add(Bytes.toBytes(HBaseTableConstants.LOOKUP_COLUMN_FAMILY),
       Bytes.toBytes(HBaseTableConstants.LOOKUP_LOCK_COLUMN), ts, lock);
-    HTable lookupTable = (HTable) tablePool.getTable(LOOKUP_TABLE);
+    HTableInterface lookupTable = tablePool.getTable(LOOKUP_TABLE);
     lookupTable.put(put);
     lookupTable.flushCommits();
     tablePool.putTable(lookupTable);
Index: occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/DatasetDeletionServiceImplTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/DatasetDeletionServiceImplTest.java	(revision 1977)
+++ occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/DatasetDeletionServiceImplTest.java	(revision )
@@ -69,7 +69,7 @@
   }
 
   @AfterClass
-  public static void afterClass() throws IOException {
+  public static void afterClass() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
   }
 
Index: occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/VerbatimOccurrencePersistenceServiceImpl.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/VerbatimOccurrencePersistenceServiceImpl.java	(revision 1977)
+++ occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/VerbatimOccurrencePersistenceServiceImpl.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.persistence;
 
+import org.apache.hadoop.hbase.client.*;
 import org.gbif.api.exception.ServiceUnavailableException;
 import org.gbif.occurrencestore.common.model.constants.FieldName;
 import org.gbif.occurrencestore.persistence.api.VerbatimOccurrence;
@@ -14,12 +15,6 @@
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.google.inject.name.Named;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -49,9 +44,9 @@
       return null;
     }
     VerbatimOccurrence occ = null;
-    HTable table = null;
+    HTableInterface table = null;
     try {
-      table = (HTable) tablePool.getTable(occurrenceTableName);
+      table = tablePool.getTable(occurrenceTableName);
       Get get = new Get(Bytes.toBytes(key));
       Result result = table.get(get);
       if (result == null || result.isEmpty()) {
@@ -63,11 +58,14 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not read from HBase", e);
     } finally {
-      if (table != null) {
+      if (table != null){
+          try {
-        tablePool.putTable(table);
+            tablePool.putTable(table);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
-      }
-    }
+          }
+      }
-
+    }
     return occ;
   }
 
@@ -77,21 +75,25 @@
     checkNotNull(occ.getKey(), "occurrence's key can't be null");
     // TODO bean validation of occ
 
-    HTable occTable = null;
+    HTableInterface occTable = null;
     try {
-      occTable = (HTable) tablePool.getTable(occurrenceTableName);
+      occTable = tablePool.getTable(occurrenceTableName);
       byte[] cf = Bytes.toBytes(HBaseTableConstants.OCCURRENCE_COLUMN_FAMILY);
       write(occTable, cf, occ, true);
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not access HBase", e);
     } finally {
-      if (occTable != null) {
+      if (occTable != null){
+          try {
-        tablePool.putTable(occTable);
+            tablePool.putTable(occTable);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
-      }
-    }
-  }
+          }
+      }
+    }
+  }
 
-  private VerbatimOccurrence write(HTable occTable, byte[] cf, VerbatimOccurrence occ, boolean dn) throws IOException {
+  private VerbatimOccurrence write(HTableInterface occTable, byte[] cf, VerbatimOccurrence occ, boolean dn) throws IOException {
     Put put = new Put(Bytes.toBytes(occ.getKey()));
     Delete del = null;
     if (dn) {
Index: occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/VerbatimOccurrencePersistenceServiceImplTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/VerbatimOccurrencePersistenceServiceImplTest.java	(revision 1977)
+++ occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/VerbatimOccurrencePersistenceServiceImplTest.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.persistence;
 
+import org.apache.hadoop.hbase.client.HTableInterface;
 import org.gbif.occurrencestore.common.model.constants.FieldName;
 import org.gbif.occurrencestore.persistence.api.VerbatimOccurrence;
 import org.gbif.occurrencestore.persistence.api.VerbatimOccurrencePersistenceService;
@@ -89,7 +90,7 @@
   }
 
   @AfterClass
-  public static void afterClass() throws IOException {
+  public static void afterClass() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
   }
 
@@ -100,7 +101,7 @@
     tablePool = new HTablePool(TEST_UTIL.getConfiguration(), 1);
 
     occurrenceService = new VerbatimOccurrencePersistenceServiceImpl(TABLE_NAME, tablePool);
-    HTable table = (HTable) tablePool.getTable(TABLE_NAME);
+    HTableInterface table = tablePool.getTable(TABLE_NAME);
     Put put = new Put(Bytes.toBytes(ID));
     put.add(CF, Bytes.toBytes(HBaseFieldUtil.getHBaseColumn(FieldName.DATASET_KEY).getColumnName()),
       Bytes.toBytes(DATASET_KEY.toString()));
Index: occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/OccurrencePersistenceServiceImpl.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/OccurrencePersistenceServiceImpl.java	(revision 1977)
+++ occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/OccurrencePersistenceServiceImpl.java	(revision )
@@ -1,6 +1,7 @@
 package org.gbif.occurrencestore.persistence;
 
 
+import org.apache.hadoop.hbase.client.*;
 import org.gbif.api.exception.ServiceUnavailableException;
 import org.gbif.api.model.common.Identifier;
 import org.gbif.api.model.occurrence.Occurrence;
@@ -22,13 +23,6 @@
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.google.inject.name.Named;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.filter.CompareFilter;
 import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -64,9 +58,9 @@
       return null;
     }
     Occurrence occ = null;
-    HTable table = null;
+    HTableInterface table = null;
     try {
-      table = (HTable) tablePool.getTable(occurrenceTableName);
+      table = tablePool.getTable(occurrenceTableName);
       Get get = new Get(Bytes.toBytes(key));
       Result result = table.get(get);
       if (result == null || result.isEmpty()) {
@@ -77,8 +71,14 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not read from HBase", e);
     } finally {
-      if (table != null) tablePool.putTable(table);
+      if (table != null) {
+          try {
+            tablePool.putTable(table);
+          } catch (IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
+          }
+      }
+    }
 
     return occ;
   }
@@ -94,9 +94,9 @@
   @Override
   public String getFragment(int key) {
     String fragment = null;
-    HTable table = null;
+    HTableInterface table = null;
     try {
-      table = (HTable) tablePool.getTable(occurrenceTableName);
+      table = tablePool.getTable(occurrenceTableName);
       Get get = new Get(Bytes.toBytes(key));
       Result result = table.get(get);
       if (result == null || result.isEmpty()) {
@@ -110,8 +110,14 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not read from HBase", e);
     } finally {
-      if (table != null) tablePool.putTable(table);
+      if (table != null) {
+          try {
+            tablePool.putTable(table);
+          } catch (IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
+          }
+      }
+    }
 
     return fragment;
   }
@@ -138,17 +144,23 @@
 
     // TODO bean validation of occ
 
-    HTable occTable = null;
+    HTableInterface occTable = null;
     try {
-      occTable = (HTable) tablePool.getTable(occurrenceTableName);
+      occTable = tablePool.getTable(occurrenceTableName);
       byte[] cf = Bytes.toBytes(HBaseTableConstants.OCCURRENCE_COLUMN_FAMILY);
       write(occTable, cf, occ, true);
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not access HBase", e);
     } finally {
-      if (occTable != null) tablePool.putTable(occTable);
+      if (occTable != null){
+          try {
+            tablePool.putTable(occTable);
+          } catch (IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
-  }
+          }
+      }
+    }
+  }
 
   @Override
   public Occurrence delete(int occurrenceKey) {
@@ -167,9 +179,9 @@
   public void delete(List<Integer> occurrenceKeys) {
     checkNotNull(occurrenceKeys, "occurrenceKeys can't be null");
 
-    HTable occTable = null;
+    HTableInterface occTable = null;
     try {
-      occTable = (HTable) tablePool.getTable(occurrenceTableName);
+      occTable = tablePool.getTable(occurrenceTableName);
       List<Delete> deletes = Lists.newArrayList();
       for (Integer occurrenceKey : occurrenceKeys) {
         if (occurrenceKey != null) {
@@ -181,12 +193,18 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not access HBase", e);
     } finally {
-      if (occTable != null) tablePool.putTable(occTable);
+      if (occTable != null){
+          try {
+            tablePool.putTable(occTable);
+          } catch (IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
-  }
+          }
+      }
+    }
+  }
 
 
-  private void write(HTable occTable, byte[] cf, Occurrence occ, boolean dn) throws IOException {
+  private void write(HTableInterface occTable, byte[] cf, Occurrence occ, boolean dn) throws IOException {
     Put put = new Put(Bytes.toBytes(occ.getKey()));
     Delete del = null;
     if (dn) del = new Delete(Bytes.toBytes(occ.getKey()));
@@ -308,7 +326,7 @@
     }
   }
 
-  private void deleteOldIdentifiers(HTable occTable, int id, byte[] columnFamily) throws IOException {
+  private void deleteOldIdentifiers(HTableInterface occTable, int id, byte[] columnFamily) throws IOException {
     Get get = new Get(Bytes.toBytes(id));
     get.addColumn(columnFamily,
       Bytes.toBytes(HBaseFieldUtil.getHBaseColumn(FieldName.IDENTIFIER_COUNT).getColumnName()));
Index: occurrence-persistence/pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/pom.xml	(revision 1977)
+++ occurrence-persistence/pom.xml	(revision )
@@ -68,6 +68,18 @@
     </dependency>
     <!-- dep:analyze reports false positive on Used undeclared hadoop -->
     <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-hdfs</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase</artifactId>
     </dependency>
Index: occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/hbase/HBaseStore.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/hbase/HBaseStore.java	(revision 1977)
+++ occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/hbase/HBaseStore.java	(revision )
@@ -1,18 +1,15 @@
 package org.gbif.occurrencestore.persistence.hbase;
 
+import org.apache.hadoop.hbase.client.*;
 import org.gbif.api.exception.ServiceUnavailableException;
 import org.gbif.hbase.util.ResultReader;
 
 import java.io.IOException;
 import javax.annotation.Nullable;
 
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -24,6 +21,7 @@
  */
 public class HBaseStore<T> {
 
+  private static final Logger LOG = LoggerFactory.getLogger(HBaseStore.class);
   private final String tableName;
   private final String cf;
   private final byte[] cfBytes;
@@ -94,9 +92,9 @@
     checkNotNull(value, "value can't be null");
 
     long result = 0;
-    HTable table = null;
+    HTableInterface table = null;
     try {
-      table = (HTable) tablePool.getTable(tableName);
+      table = tablePool.getTable(tableName);
       byte[] byteKey = convertKey(key);
       if (byteKey != null) {
         result = table.incrementColumnValue(byteKey, cfBytes, Bytes.toBytes(columnName), value);
@@ -104,8 +102,14 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not read from HBase", e);
     } finally {
-      if (table != null) tablePool.putTable(table);
+      if (table != null){
+          try {
+            tablePool.putTable(table);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
+          }
+      }
+    }
 
     return result;
   }
@@ -115,9 +119,9 @@
     checkNotNull(columnName, "columnName can't be null");
     checkNotNull(value, "value can't be null");
 
-    HTable table = null;
+    HTableInterface table = null;
     try {
-      table = (HTable) tablePool.getTable(tableName);
+      table = tablePool.getTable(tableName);
       byte[] byteKey = convertKey(key);
       if (byteKey != null) {
         Put put = new Put(byteKey);
@@ -128,18 +132,24 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not read from HBase", e);
     } finally {
-      if (table != null) tablePool.putTable(table);
+      if (table != null){
+          try {
+            tablePool.putTable(table);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
-  }
+          }
+      }
+    }
+  }
 
   public Result getRow(T key, String columnName) {
     checkNotNull(key, "key can't be null");
     checkNotNull(columnName, "columnName can't be null");
 
-    HTable table = null;
+    HTableInterface table = null;
     Result row = null;
     try {
-      table = (HTable) tablePool.getTable(tableName);
+      table = tablePool.getTable(tableName);
       byte[] byteKey = convertKey(key);
       if (byteKey != null) {
         Get get = new Get(byteKey);
@@ -149,8 +159,14 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not read from HBase", e);
     } finally {
-      if (table != null) tablePool.putTable(table);
+      if (table != null){
+          try {
+            tablePool.putTable(table);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
+          }
+      }
+    }
 
     return row;
   }
@@ -159,10 +175,10 @@
   public Result getRow(T key) {
     checkNotNull(key, "key can't be null");
 
-    HTable table = null;
+    HTableInterface table = null;
     Result row = null;
     try {
-      table = (HTable) tablePool.getTable(tableName);
+      table = tablePool.getTable(tableName);
       byte[] byteKey = convertKey(key);
       if (byteKey != null) {
         Get get = new Get(byteKey);
@@ -171,8 +187,14 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not read from HBase", e);
     } finally {
-      if (table != null) tablePool.putTable(table);
+      if (table != null){
+          try {
+            tablePool.putTable(table);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
+          }
+      }
+    }
 
     return row;
   }
@@ -185,9 +207,9 @@
     checkNotNull(checkColumn, "checkColumn can't be null");
 
     boolean success = false;
-    HTable table = null;
+    HTableInterface table = null;
     try {
-      table = (HTable) tablePool.getTable(tableName);
+      table = tablePool.getTable(tableName);
       byte[] byteKey = convertKey(key);
       if (byteKey != null) {
         Put put = new Put(byteKey);
@@ -201,8 +223,14 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not read from HBase", e);
     } finally {
-      if (table != null) tablePool.putTable(table);
+      if (table != null){
+          try {
+            tablePool.putTable(table);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
+          }
+      }
+    }
 
     return success;
   }
@@ -211,9 +239,9 @@
     checkNotNull(key, "key can't be null");
     checkArgument(columns.length > 0, "columns can't be empty");
 
-    HTable table = null;
+    HTableInterface table = null;
     try {
-      table = (HTable) tablePool.getTable(tableName);
+      table = tablePool.getTable(tableName);
       byte[] byteKey = convertKey(key);
       if (byteKey != null) {
         Delete delete = new Delete(byteKey);
@@ -226,7 +254,13 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not read from HBase", e);
     } finally {
-      if (table != null) tablePool.putTable(table);
+      if (table != null){
+          try {
+            tablePool.putTable(table);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
+          }
+      }
     }
   }
 
Index: occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/OccurrenceKeyIterator.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/OccurrenceKeyIterator.java	(revision 1977)
+++ occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/OccurrenceKeyIterator.java	(revision )
@@ -1,16 +1,12 @@
 package org.gbif.occurrencestore.persistence;
 
+import org.apache.hadoop.hbase.client.*;
 import org.gbif.service.exception.PersistenceException;
 
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -25,7 +21,7 @@
   private final ResultScanner scanner;
   private final Iterator<Result> iterator;
   private final HTablePool tablePool;
-  private final HTable table;
+  private final HTableInterface table;
   private boolean scannerClosed = false;
 
   /**
@@ -39,12 +35,18 @@
   public OccurrenceKeyIterator(HTablePool tablePool, String occurrenceTableName, Scan scan) {
     // TODO: heartbeat thread to shutdown/close resources if no activity after x seconds?
     this.tablePool = tablePool;
-    this.table = (HTable) tablePool.getTable(occurrenceTableName);
+    this.table = tablePool.getTable(occurrenceTableName);
     try {
       this.scanner = table.getScanner(scan);
       this.iterator = scanner.iterator();
     } catch (IOException e) {
-      if (table != null) tablePool.putTable(table);
+      if (table != null) {
+          try {
+            tablePool.putTable(table);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
+          }
+      }
       throw new PersistenceException("Could not read from HBase", e);
     }
   }
@@ -57,7 +59,13 @@
       return true;
     } else {
       scanner.close();
-      if (table != null) tablePool.putTable(table);
+      if (table != null) {
+          try {
+            tablePool.putTable(table);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
+          }
+      }
       scannerClosed = true;
       return false;
     }
Index: occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/KeyPersistenceServiceTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/KeyPersistenceServiceTest.java	(revision 1977)
+++ occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/KeyPersistenceServiceTest.java	(revision )
@@ -84,7 +84,7 @@
   }
 
   @AfterClass
-  public static void afterClass() throws IOException {
+  public static void afterClass() throws Exception {
     CURATOR.close();
     ZOOKEEPER_SERVER.stop();
     TEST_UTIL.shutdownMiniCluster();
Index: occurrence-deleter/src/test/java/org/gbif/occurrencestore/deleter/OccurrenceDeletionServiceTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-deleter/src/test/java/org/gbif/occurrencestore/deleter/OccurrenceDeletionServiceTest.java	(revision 1977)
+++ occurrence-deleter/src/test/java/org/gbif/occurrencestore/deleter/OccurrenceDeletionServiceTest.java	(revision )
@@ -73,7 +73,7 @@
   }
 
   @AfterClass
-  public static void afterClass() throws IOException {
+  public static void afterClass() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
   }
 
Index: occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/OccurrencePersistenceServiceImplTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/OccurrencePersistenceServiceImplTest.java	(revision 1977)
+++ occurrence-persistence/src/test/java/org/gbif/occurrencestore/persistence/OccurrencePersistenceServiceImplTest.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.persistence;
 
+import org.apache.hadoop.hbase.client.HTableInterface;
 import org.gbif.api.model.common.Identifier;
 import org.gbif.api.model.occurrence.Occurrence;
 import org.gbif.api.vocabulary.BasisOfRecord;
@@ -104,7 +105,7 @@
   private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
 
   @AfterClass
-  public static void afterClass() throws IOException {
+  public static void afterClass() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
   }
 
@@ -172,7 +173,7 @@
     tablePool = new HTablePool(TEST_UTIL.getConfiguration(), 1);
 
     occurrenceService = new OccurrencePersistenceServiceImpl(TABLE_NAME, tablePool);
-    HTable table = (HTable) tablePool.getTable(TABLE_NAME);
+    HTableInterface table = tablePool.getTable(TABLE_NAME);
     Put put = new Put(Bytes.toBytes(ID));
     put.add(CF, Bytes.toBytes(HBaseFieldUtil.getHBaseColumn(FieldName.I_ALTITUDE).getColumnName()), Bytes.toBytes(ALT));
     put.add(CF, Bytes.toBytes(HBaseFieldUtil.getHBaseColumn(FieldName.I_BASIS_OF_RECORD).getColumnName()),
@@ -272,7 +273,7 @@
   }
 
   private void setUpIdentifiers() throws IOException {
-    HTable table = (HTable) tablePool.getTable(TABLE_NAME);
+    HTableInterface table = tablePool.getTable(TABLE_NAME);
     Put put = new Put(Bytes.toBytes(ID));
     put.add(CF, Bytes.toBytes(HBaseTableConstants.IDENTIFIER_COLUMN + 0), Bytes.toBytes(ID_0));
     put.add(CF, Bytes.toBytes(HBaseTableConstants.IDENTIFIER_TYPE_COLUMN + 0), Bytes.toBytes(ID_TYPE_0));
Index: occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/FragmentPersistenceServiceImpl.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/FragmentPersistenceServiceImpl.java	(revision 1977)
+++ occurrence-persistence/src/main/java/org/gbif/occurrencestore/persistence/FragmentPersistenceServiceImpl.java	(revision )
@@ -1,5 +1,6 @@
 package org.gbif.occurrencestore.persistence;
 
+import org.apache.hadoop.hbase.client.*;
 import org.gbif.api.exception.ServiceUnavailableException;
 import org.gbif.occurrencestore.common.model.UniqueIdentifier;
 import org.gbif.occurrencestore.common.model.constants.FieldName;
@@ -18,12 +19,6 @@
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.google.inject.name.Named;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -57,9 +52,9 @@
     }
 
     Fragment frag = null;
-    HTable table = null;
+    HTableInterface table = null;
     try {
-      table = (HTable) tablePool.getTable(occurrenceTableName);
+      table = tablePool.getTable(occurrenceTableName);
       Get get = new Get(Bytes.toBytes(key));
       Result result = table.get(get);
       if (result == null || result.isEmpty()) {
@@ -70,8 +65,14 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not read from HBase", e);
     } finally {
-      if (table != null) tablePool.putTable(table);
+      if (table != null){
+          try {
+            tablePool.putTable(table);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
+          }
+      }
+    }
 
     return frag;
   }
@@ -100,9 +101,9 @@
       checkNotNull(uniqueIds, "uniqueIds can't be null if createKey is true");
     }
 
-    HTable occTable = null;
+    HTableInterface occTable = null;
     try {
-      occTable = (HTable) tablePool.getTable(occurrenceTableName);
+      occTable = (HTableInterface) tablePool.getTable(occurrenceTableName);
       byte[] cf = Bytes.toBytes(HBaseTableConstants.OCCURRENCE_COLUMN_FAMILY);
       if (createKey) {
         KeyLookupResult keyLookupResult = keyService.generateKey(uniqueIds);
@@ -112,9 +113,15 @@
     } catch (IOException e) {
       throw new ServiceUnavailableException("Could not access HBase", e);
     } finally {
-      if (occTable != null) tablePool.putTable(occTable);
+      if (occTable != null){
+          try {
+            tablePool.putTable(occTable);
+          } catch(IOException ex){
+              LOG.error(ex.getMessage(),ex);
-    }
-  }
+          }
+      }
+    }
+  }
 
   /**
    * Writes all fields of Fragment to the HBase table. If dn (deleteNulls) is true, any field in the fragment that is
@@ -128,7 +135,7 @@
    *
    * @throws IOException if communicating with HBase fails
    */
-  private void writeFields(HTable occTable, byte[] cf, Fragment frag, boolean dn) throws IOException {
+  private void writeFields(HTableInterface occTable, byte[] cf, Fragment frag, boolean dn) throws IOException {
     Put put = new Put(Bytes.toBytes(frag.getKey()));
     Delete del = null;
     if (dn) del = new Delete(Bytes.toBytes(frag.getKey()));
