You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Nichole Treadway <kn...@gmail.com> on 2011/08/15 01:27:14 UTC
ZKConfig.makeZKProps throwing NullPointerException
Hi all,
I am getting the below error when trying to create a new HTable object (see
end of email)...
I believe the error is occuring in the below function because the
getClassLoader() function is returning null. Because the way my application
is set up, I have to add all hbase, hadoop, and zookeeper-related jars to
the bootstrap classpath using the java "-Xbootclasspath/p" flag. I think
this is causing some kind of issue with the classloader. Any one have any
ideas what I can do to resolve this?
public static Properties makeZKProps(Configuration conf) {
// First check if there is a zoo.cfg in the CLASSPATH. If so, simply
read
// it and grab its configuration properties.
* ClassLoader cl = HQuorumPeer.class.getClassLoader();*
* final InputStream inputStream =
cl.getResourceAsStream(HConstants.ZOOKEEPER_CONFIG_NAME);*
if (inputStream != null) {
try {
return parseZooCfg(conf, inputStream);
} catch (IOException e) {
LOG.warn("Cannot read " + HConstants.ZOOKEEPER_CONFIG_NAME +
", loading from XML files", e);
}
}
Stacktrace:
11/08/14 19:18:43 java.lang.NullPointerException
at org.apache.hadoop.hbase.zookeeper.ZKConfig.makeZKProps(ZKConfig.java:65)
at
org.apache.hadoop.hbase.zookeeper.ZKConfig.getZKQuorumServersString(ZKConfig.java:250)
at
org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:117)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getZooKeeperWatcher(HConnectionManager.java:1255)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.setupZookeeperTrackers(HConnectionManager.java:515)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.<init>(HConnectionManager.java:506)
at
org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:180)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:180)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:158)
Re: ZKConfig.makeZKProps throwing NullPointerException
Posted by Jean-Daniel Cryans <jd...@apache.org>.
The getClassLoader javadoc says:
This method will return null in such implementations if this class was
loaded by the bootstrap class loader.
So if I understand correctly, we need to add additional checks in that
method to guard HBase against people like you? :)
J-D
On Mon, Aug 15, 2011 at 5:47 AM, Nichole Treadway <kn...@gmail.com> wrote:
> Sorry, I forgot to mention:
>
> I'm using hadoop-0.20-append, hbase-0.92 on two red hat 5.5 machines.
>
> The function I pasted is in org.apache.hadoop.hbase.zookeeper.ZKConfig.
>
>
> On Aug 14, 2011, at 7:27 PM, Nichole Treadway wrote:
>
>> Hi all,
>>
>> I am getting the below error when trying to create a new HTable object (see end of email)...
>>
>> I believe the error is occuring in the below function because the getClassLoader() function is returning null. Because the way my application is set up, I have to add all hbase, hadoop, and zookeeper-related jars to the bootstrap classpath using the java "-Xbootclasspath/p" flag. I think this is causing some kind of issue with the classloader. Any one have any ideas what I can do to resolve this?
>>
>> public static Properties makeZKProps(Configuration conf) {
>> // First check if there is a zoo.cfg in the CLASSPATH. If so, simply read
>> // it and grab its configuration properties.
>> ClassLoader cl = HQuorumPeer.class.getClassLoader();
>> final InputStream inputStream = cl.getResourceAsStream(HConstants.ZOOKEEPER_CONFIG_NAME);
>> if (inputStream != null) {
>> try {
>> return parseZooCfg(conf, inputStream);
>> } catch (IOException e) {
>> LOG.warn("Cannot read " + HConstants.ZOOKEEPER_CONFIG_NAME +
>> ", loading from XML files", e);
>> }
>> }
>>
>>
>> Stacktrace:
>>
>> 11/08/14 19:18:43 java.lang.NullPointerException
>> at org.apache.hadoop.hbase.zookeeper.ZKConfig.makeZKProps(ZKConfig.java:65)
>> at org.apache.hadoop.hbase.zookeeper.ZKConfig.getZKQuorumServersString(ZKConfig.java:250)
>> at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:117)
>> at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getZooKeeperWatcher(HConnectionManager.java:1255)
>> at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.setupZookeeperTrackers(HConnectionManager.java:515)
>> at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.<init>(HConnectionManager.java:506)
>> at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:180)
>> at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:180)
>> at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:158)
>
>
Re: ZKConfig.makeZKProps throwing NullPointerException
Posted by Nichole Treadway <kn...@gmail.com>.
Sorry, I forgot to mention:
I'm using hadoop-0.20-append, hbase-0.92 on two red hat 5.5 machines.
The function I pasted is in org.apache.hadoop.hbase.zookeeper.ZKConfig.
On Aug 14, 2011, at 7:27 PM, Nichole Treadway wrote:
> Hi all,
>
> I am getting the below error when trying to create a new HTable object (see end of email)...
>
> I believe the error is occuring in the below function because the getClassLoader() function is returning null. Because the way my application is set up, I have to add all hbase, hadoop, and zookeeper-related jars to the bootstrap classpath using the java "-Xbootclasspath/p" flag. I think this is causing some kind of issue with the classloader. Any one have any ideas what I can do to resolve this?
>
> public static Properties makeZKProps(Configuration conf) {
> // First check if there is a zoo.cfg in the CLASSPATH. If so, simply read
> // it and grab its configuration properties.
> ClassLoader cl = HQuorumPeer.class.getClassLoader();
> final InputStream inputStream = cl.getResourceAsStream(HConstants.ZOOKEEPER_CONFIG_NAME);
> if (inputStream != null) {
> try {
> return parseZooCfg(conf, inputStream);
> } catch (IOException e) {
> LOG.warn("Cannot read " + HConstants.ZOOKEEPER_CONFIG_NAME +
> ", loading from XML files", e);
> }
> }
>
>
> Stacktrace:
>
> 11/08/14 19:18:43 java.lang.NullPointerException
> at org.apache.hadoop.hbase.zookeeper.ZKConfig.makeZKProps(ZKConfig.java:65)
> at org.apache.hadoop.hbase.zookeeper.ZKConfig.getZKQuorumServersString(ZKConfig.java:250)
> at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:117)
> at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getZooKeeperWatcher(HConnectionManager.java:1255)
> at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.setupZookeeperTrackers(HConnectionManager.java:515)
> at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.<init>(HConnectionManager.java:506)
> at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:180)
> at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:180)
> at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:158)