scala - Why can't my jar see the HBase configuration from the environment? -


i wrote application tried create default hbaseconfiguration, when package application jar won't work because trying use 127.0.0.1's zookeeper , not 1 specified in /etc/hbase/conf/hbase-site.xml. application can stripped down this:

 object testutil extends app {    val hbasetable = new htable(hbaseconfiguration.create, "tablename")    println(hbasetable)  } 

when run using following command works fine:

 classpath=`hbase classpath` java fully.qualified.name.testutil 

if package jar , call using classpath='hbase classpath' java -jar testutil.jar following error:

 org.apache.hadoop.hbase.zookeeperconnectionexception: hbase able connect zookeeper connection closes immediately. 

i've checked logs , can see trying connect 127.0.0.1 zookeeper, different zookeeper configuration in /etc/hbase/conf/hbase-site.xml. jar seems ignoring classpath though explicitly set on command line.

how can make jvm honor classpath when executing jar?

when starting jvm java -jar resulting environment not see files in classpath outside classpath variable. instead uses classpath manifest file.

assuming don't want hardcode paths dependencies in manifest, can around by:

  1. putting jar want run in class path in addition to,
  2. not using -jar switch, and
  3. specifying class main() argument.

for example:

 classpath=/path/to/my.jar:`hbase classpath` java fully.qualified.mainclass 

this same approach hbase's hbase shell script uses. take @ line 332.

so long jar doesn't include hbase-site.xml, approach should result in jvm loading hbase-site.xml classpath.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -