由于上述错误,我的基于tomcat的REST API应用程序无法处理请求。到目前为止,我尝试过以下事项:
tomcat/webapp/
目录然后也得到以下异常。我使用的CDH 5.3.1
包含HBase 0.98.6
。有谁知道如何解决这个问题?
2015-03-03 05:09:02 privateLog [ERROR] java.lang.reflect.InvocationTargetException org.apache.hadoop.hbase.client.HConnectionManager.createConnection(HConnectionManager.java:413)
org.apache.hadoop.hbase.client.HConnectionManager.createConnection(HConnectionManager.java:306)
com.amazon.dao.MyDAO.<clinit>(SensorDataDAO.java:78)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:526)
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
java.util.concurrent.FutureTask.run(FutureTask.java:166)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:724)
com.amazon.dao.MyDAO <clinit>
尝试建立连接的代码如下:
public class MyDAO {
protected static HConnection connection;
static {
Configuration conf = HBaseConfiguration.create();
conf.addResource("hbase-site.xml");
connection = HConnectionManager.createConnection(conf);
// connection object is still null at this point
try {
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
答案 0 :(得分:2)
您可以尝试将此设置为您的conf吗?
config.set("hbase.zookeeper.quorum", "zookeeper-ip:port");
如果这样可行,那么我们可以检查您设置为conf的hbase-site.xml是否具有正确的详细信息。
答案 1 :(得分:0)
我解决了我的问题。我发现了这个错误的2个原因。如果有人面临同样的错误,那么这个答案可能有助于他们:)
/etc/hadoop
,/etc/hadoop-hdfs
,/etc/hbase
和/etc/zookeeper
目录中。 请注意我们正在使用Cloudera Hadoop发行版,如果 你正在使用一些不同的分布,那么这些路径可能会有所不同。
hdfs-site.xml
文件。由于我们使用名称节点HA功能,因此必须使用此文件。如果此文件不存在,则hbase无法连接到正确的名称节点服务。现在连接相关代码如下所示:
public class MyDAO {
protected static HConnection connection;
static {
Configuration conf = HBaseConfiguration.create();
conf.addResource("hbase-site.xml");
conf.addResource("hdfs-site.xml");
conf.addResource("core-site.xml");
connection = HConnectionManager.createConnection(conf);
try {
} catch (Exception ex) {
ex.printStackTrace();
}
}
}