1

看来我无法从 AppEngine 上运行的 Java 类创建连接。

我使用以下库/依赖项:

<dependency>
   <groupId>com.google.cloud.bigtable</groupId>
   <artifactId>bigtable-hbase-1.1</artifactId>
   <version>0.1.9</version>
</dependency>

以及以下代码行:

import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.*;
Configuration conf = HBaseConfiguration.create();
connection  = ConnectionFactory.createConnection(conf);

ConnectionFactory.createConnection()方法似乎试图使用受限类。

您能帮我们解释一下如何在 GAE 上使用它吗?

在 devserver 上本地运行时出现以下错误:

 Caused by: java.lang.NoClassDefFoundError: java.lang.management.ManagementFactory is a restricted class. Please see the Google  App Engine developer's guide for more details.
    at     com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:52)
        at org.apache.hadoop.util.ReflectionUtils.<clinit>(ReflectionUtils.java:137)
        at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:191)
    at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
    at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:65)
    at org.apache.hadoop.hbase.security.UserProvider.instantiate(UserProvider.java:45)
    at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:214)
    at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:119)
    at org.energyworx.datastore.BigTableTSStorage.<init>(BigTableTSStorage.java:104)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:379)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:373)
    ... 71 more
4

1 回答 1

1

我已经更新了GitHub 上的示例。

于 2015-07-14T00:04:18.467 回答