java—如何在没有任何cli命令的情况下运行hive嵌入式服务器

jvlzgdj9  于 2021-06-24  发布在  Hive
关注(0)|答案(0)|浏览(506)

我正在尝试创建到hive嵌入式服务器的连接。

try {
 Class.forName("org.apache.hive.jdbc.HiveDriver");
} catch (ClassNotFoundException e) {
    e.printStackTrace();
    System.exit(1);
}

Connection con = DriverManager.getConnection("jdbc:hive2:///", "", "");
Statement stmt = con.createStatement();
String tableName = "testHiveDriverTable";
stmt.execute("drop table if exists " + tableName);
stmt.execute("create table " + tableName + " (key int, value string)");

hive-site.xml无效

<configuration>
  <property>
    <name>hive.metastore.schema.verification</name>
    <value>false</value>
    <description>location of default database for the warehouse</description>
  </property>
  <property>
    <name>datanucleus.schema.autoCreateTables</name>
    <value>true</value>
    <description>location of default database for the warehouse</description>
  </property>
  <property>
    <name>hive.security.authorization.enabled</name>
    <value>false</value>
    <description>enable or disable the Hive client authorization</description>
  </property>
</configuration>

当我运行代码时,抛出以下错误。

ERROR org.apache.hadoop.hive.metastore.RetryingHMSHandler - Retrying HMSHandler after 2000 ms (attempt 1 of 10) with error: javax.jdo.JDOUserException: Identifier principalName is unresolved (not a static field)
    at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:636)
    at org.datanucleus.api.jdo.JDOQuery.executeInternal(JDOQuery.java:391)
    at org.datanucleus.api.jdo.JDOQuery.executeWithArray(JDOQuery.java:267)
    at org.apache.hadoop.hive.metastore.ObjectStore.listPrincipalMGlobalGrants(ObjectStore.java:5078)
    at org.apache.hadoop.hive.metastore.ObjectStore.grantPrivileges(ObjectStore.java:4588)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.hadoop.hive.metastore.RawStoreProxy.invoke(RawStoreProxy.java:101)
    at com.sun.proxy.$Proxy13.grantPrivileges(Unknown Source)
    at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultRoles_core(HiveMetaStore.java:714)
    at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultRoles(HiveMetaStore.java:683)
    at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.init(HiveMetaStore.java:432)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invokeInternal(RetryingHMSHandler.java:148)
    at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invoke(RetryingHMSHandler.java:107)
    at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:79)
    at org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy(RetryingHMSHandler.java:92)
    at org.apache.hadoop.hive.metastore.HiveMetaStore.newRetryingHMSHandler(HiveMetaStore.java:6891)
    at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:164)
    at org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient.<init>(SessionHiveMetaStoreClient.java:70)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1706)
    at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.<init>(RetryingMetaStoreClient.java:83)
    at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:133)
    at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:104)
    at org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:3600)
    at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:3652)
    at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:3632)
    at org.apache.hadoop.hive.ql.metadata.Hive.getAllFunctions(Hive.java:3894)
    at org.apache.hadoop.hive.ql.metadata.Hive.reloadFunctions(Hive.java:248)
    at org.apache.hadoop.hive.ql.metadata.Hive.registerAllFunctionsOnce(Hive.java:231)
    at org.apache.hadoop.hive.ql.metadata.Hive.<init>(Hive.java:388)
    at org.apache.hadoop.hive.ql.metadata.Hive.create(Hive.java:332)
    at org.apache.hadoop.hive.ql.metadata.Hive.getInternal(Hive.java:312)
    at org.apache.hadoop.hive.ql.metadata.Hive.get(Hive.java:288)
    at org.apache.hadoop.hive.ql.session.SessionState.setAuthorizerV2Config(SessionState.java:913)
    at org.apache.hadoop.hive.ql.session.SessionState.setupAuth(SessionState.java:877)
    at org.apache.hadoop.hive.ql.session.SessionState.applyAuthorizationPolicy(SessionState.java:1683)
    at org.apache.hive.service.cli.CLIService.applyAuthorizationConfigPolicy(CLIService.java:130)
    at org.apache.hive.service.cli.CLIService.init(CLIService.java:114)
    at org.apache.hive.service.cli.thrift.EmbeddedThriftBinaryCLIService.init(EmbeddedThriftBinaryCLIService.java:45)
    at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:177)
    at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at org.apache.hive.HiveEmbeddedTest.main(HiveEmbeddedTest.java:26)
NestedThrowablesStackTrace:
Identifier principalName is unresolved (not a static field)
org.datanucleus.exceptions.NucleusUserException: Identifier principalName is unresolved (not a static field)
    at org.datanucleus.query.expression.PrimaryExpression.bind(PrimaryExpression.java:182)
    at org.datanucleus.query.expression.DyadicExpression.bind(DyadicExpression.java:89)
    at org.datanucleus.query.expression.DyadicExpression.bind(DyadicExpression.java:89)
    at org.datanucleus.query.compiler.JavaQueryCompiler.compileFilter(JavaQueryCompiler.java:539)
    at org.datanucleus.query.compiler.JDOQLCompiler.compile(JDOQLCompiler.java:116)
    at org.datanucleus.store.query.AbstractJDOQLQuery.compileGeneric(AbstractJDOQLQuery.java:370)
    at org.datanucleus.store.query.AbstractJDOQLQuery.compileInternal(AbstractJDOQLQuery.java:415)
    at org.datanucleus.store.rdbms.query.JDOQLQuery.compileInternal(JDOQLQuery.java:239)
    at org.datanucleus.store.query.Query.executeQuery(Query.java:1816)
    at org.datanucleus.store.query.Query.executeWithArray(Query.java:1744)
    at org.datanucleus.api.jdo.JDOQuery.executeInternal(JDOQuery.java:368)
    at org.datanucleus.api.jdo.JDOQuery.executeWithArray(JDOQuery.java:267)
    at org.apache.hadoop.hive.metastore.ObjectStore.listPrincipalMGlobalGrants(ObjectStore.java:5078)
    at org.apache.hadoop.hive.metastore.ObjectStore.grantPrivileges(ObjectStore.java:4588)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.hadoop.hive.metastore.RawStoreProxy.invoke(RawStoreProxy.java:101)
    at com.sun.proxy.$Proxy13.grantPrivileges(Unknown Source)
    at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultRoles_core(HiveMetaStore.java:714)
    at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultRoles(HiveMetaStore.java:683)
    at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.init(HiveMetaStore.java:432)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invokeInternal(RetryingHMSHandler.java:148)
    at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invoke(RetryingHMSHandler.java:107)
    at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:79)
    at org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy(RetryingHMSHandler.java:92)
    at org.apache.hadoop.hive.metastore.HiveMetaStore.newRetryingHMSHandler(HiveMetaStore.java:6891)
    at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:164)
    at org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient.<init>(SessionHiveMetaStoreClient.java:70)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1706)
    at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.<init>(RetryingMetaStoreClient.java:83)
    at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:133)
    at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:104)
    at org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:3600)
    at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:3652)
    at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:3632)
    at org.apache.hadoop.hive.ql.metadata.Hive.getAllFunctions(Hive.java:3894)
    at org.apache.hadoop.hive.ql.metadata.Hive.reloadFunctions(Hive.java:248)
    at org.apache.hadoop.hive.ql.metadata.Hive.registerAllFunctionsOnce(Hive.java:231)
    at org.apache.hadoop.hive.ql.metadata.Hive.<init>(Hive.java:388)
    at org.apache.hadoop.hive.ql.metadata.Hive.create(Hive.java:332)
    at org.apache.hadoop.hive.ql.metadata.Hive.getInternal(Hive.java:312)
    at org.apache.hadoop.hive.ql.metadata.Hive.get(Hive.java:288)
    at org.apache.hadoop.hive.ql.session.SessionState.setAuthorizerV2Config(SessionState.java:913)
    at org.apache.hadoop.hive.ql.session.SessionState.setupAuth(SessionState.java:877)
    at org.apache.hadoop.hive.ql.session.SessionState.applyAuthorizationPolicy(SessionState.java:1683)
    at org.apache.hive.service.cli.CLIService.applyAuthorizationConfigPolicy(CLIService.java:130)
    at org.apache.hive.service.cli.CLIService.init(CLIService.java:114)
    at org.apache.hive.service.cli.thrift.EmbeddedThriftBinaryCLIService.init(EmbeddedThriftBinaryCLIService.java:45)
    at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:177)
    at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at org.apache.hive.HiveEmbeddedTest.main(HiveEmbeddedTest.java:26)

如果有人能解释如何克服这个错误,那就太好了。我不明白,为什么它在使用hiveserver2嵌入式服务器时尝试解析主体名称。
提前谢谢。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题