问题
It appears that I cannot create a connection from Java class running on AppEngine.
I use the following library/dependency:
<dependency>
<groupId>com.google.cloud.bigtable</groupId>
<artifactId>bigtable-hbase-1.1</artifactId>
<version>0.1.9</version>
</dependency>
And the following lines of code:
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.*;
Configuration conf = HBaseConfiguration.create();
connection = ConnectionFactory.createConnection(conf);
It appears that the ConnectionFactory.createConnection()
method tries to use a restricted class.
Could you help us in explaining how we can use this on GAE?
I get the following error when running locally on 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
回答1:
I've updated the sample on GitHub.
来源:https://stackoverflow.com/questions/31101156/connect-to-cloud-bigtable-from-google-app-engine