Well after digging (and digging... and digging some more) it turns out
the source of the problem is in the Groovy Ant task.  Rather, the fact
that ....hbase.Configuration uses the
Thread.getCurrentThread().getContextClassloader(), which the Groovy
Ant task leaves as the system classpath, as opposed to the <groovy
classpathref='_____'> value.  So none of the HBase JARs were available
to that classloader...  Which is why HBase couldn't find
hbase-default.xml or hbase-site.xml.



On Mon, Feb 2, 2009 at 12:07 PM, Tom Nichols <[email protected]> wrote:
> Hi,
>
> I am using the HBase client API in from a Groovy script:
>
> import org.apache.hadoop.hbase.HBaseConfiguration
> import org.apache.hadoop.hbase.client.HBaseAdmin
> println new HBaseAdmin( new HBaseConfiguration() )
>
> The script works fine if run standalone, but if I run it as an embeded
> ant task, I get the following exception:
>
> java.lang.NullPointerException
>        at 
> java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
>        at 
> org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:90)
>        at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:66)
>        at 
> com.enernoc.rnd.shredder.core.groovy.HBaseBuilder.getAdmin(HBaseBuilder.java:530)
>        at 
> com.enernoc.rnd.shredder.core.groovy.HBaseBuilder.create(HBaseBuilder.java:229)
>
>
> Looking into the code:
> 86 :                     public static HConnection 
> getConnection(HBaseConfiguration conf) {
> 87 :                    TableServers connection;
> 88 :                    synchronized (HBASE_INSTANCES) {
> 89 :                    String instanceName = conf.get(HBASE_DIR);
> 90 :                    connection = HBASE_INSTANCES.get(instanceName);
>
> It means that either "instanceName" is null, or HBASE_INSTANCES is
> null.  I am guessing it is the former since the previous line is
> retrieving that value.   So can anyone guess why this would fail?  The
> HBase JAR is on my classpath, which contains the hbase-default.xml
> config file (which has the hbase.rootdir value).
>
> Furthermore, it appears that the value "hbase.rootdir" is a server
> configuration to tell the HBase server where the data is stored --
> correct?  So if I am just using the client api (i.e. to connect to a
> running HBase server instance,) why would the client be attempting to
> directly access the data files rather than going through the server
> connection?  Or am I confused about how the HBase API works?
>
> Thanks in advance for the help.
>
> -Tom
>

Reply via email to