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:
- putting jar want run in class path in addition to,
- not using
-jarswitch, and - 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
Post a Comment