0 Replies Latest reply on Oct 10, 2014 6:02 AM by Viktor Purnyn

    Cannot connect to HBase from WildFly

    Viktor Purnyn Newbie

      Hello everyone,

       

      I've encountered strange problem while trying to connect to HBase 0.98.5-hadoop2  database from EJB deployed onto WildFly 8.1.0.Final.

       

      This code works perfectly as standalone application:

       

          public static void main(String[] args) throws IOException {

             Configuration config = getConfiguration();

             HConnection connection = HConnectionManager.createConnection(config);

          }

          private static Configuration getConfiguration() {

             Configuration config = HBaseConfiguration.create();

             config.set("hbase.zookeeper.quorum", "hbase");  //

             config.set("hbase.client.retries.number", "3");  //

             config.set("hbase.cluster.distributed", "true");

             return config;

          }

       

             

      but when I include it into EJB and run from server I've got following exception:

       

      > 2014-10-09 11:58:57,737 ERROR [org.jboss.as.ejb3.invocation] (EJB

      > default - 2) JBAS014134: EJB Invocation failed on component

      > HbaseExecutorImpl for method public abstract void

      > hbasetest.HbaseExecutor.testConnect(): javax.ejb.EJBException:

      > java.lang.RuntimeException: java.io.IOException: failure to login     at

      > org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:190)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:340)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:79)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:43)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:95)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)

      >     at

      > org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:448)

      >     at

      > org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)

      >     at

      > org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

      >     at

      > org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:185)

      >     at

      > org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.invokeMethod(MethodInvocationMessageHandler.java:330)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.access$100(MethodInvocationMessageHandler.java:70)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler$1.run(MethodInvocationMessageHandler.java:203)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)

      > [rt.jar:1.7.0_67]     at

      > java.util.concurrent.FutureTask.run(FutureTask.java:262)

      > [rt.jar:1.7.0_67]     at

      > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

      > [rt.jar:1.7.0_67]     at

      > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

      > [rt.jar:1.7.0_67]     at java.lang.Thread.run(Thread.java:745)

      > [rt.jar:1.7.0_67]     at

      > org.jboss.threads.JBossThread.run(JBossThread.java:122) Caused by:

      > java.lang.RuntimeException: java.io.IOException: failure to login     at

      > hbasetest.HbaseExecutorImpl.testConnect(HbaseExecutorImpl.java:21)

      > [db2test-1.0-SNAPSHOT.jar:]     at

      > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      > [rt.jar:1.7.0_67]     at

      > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

      > [rt.jar:1.7.0_67]     at

      > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      > [rt.jar:1.7.0_67]     at java.lang.reflect.Method.invoke(Method.java:606)

      > [rt.jar:1.7.0_67]     at

      > org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

      >     at

      > org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)

      >     at

      > org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82)

      > [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93)

      > [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

      >     at

      > org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)

      >     at

      > org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55)

      > [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]     at

      > org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83)

      > [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)

      > [wildfly-ee-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

      >     at

      > org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

      >     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ejb3.component.interceptors.NonPooledEJBComponentInstanceAssociatingInterceptor.processInvocation(NonPooledEJBComponentInstanceAssociatingInterceptor.java:59)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     at

      > org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

      >     at

      > org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:273)

      > [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]     ... 39 more Caused by:

      > java.io.IOException: failure to login     at

      > org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:700)

      > [hadoop-common-2.2.0.jar:]     at

      > org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:571)

      > [hadoop-common-2.2.0.jar:]     at

      > hbasetest.HbaseExecutorImpl.testConnect(HbaseExecutorImpl.java:19)

      > [db2test-1.0-SNAPSHOT.jar:]     ... 74 more Caused by:

      > javax.security.auth.login.LoginException: unable to find LoginModule

      > class: com.sun.security.auth.module.NTLoginModule from [Module

      > "com.something.hbaseclient:main" from local module loader @64f40c1f

      > (finder: local module finder @5247fb00 (roots:

      > C:\opt\dtv\wildfly-8.1.0.Final\modules,C:\opt\dtv\wildfly-8.1.0.Final\modules\system\layers\base))]

      >     at

      > javax.security.auth.login.LoginContext.invoke(LoginContext.java:800)

      > [rt.jar:1.7.0_67]     at

      > javax.security.auth.login.LoginContext.access$000(LoginContext.java:203)

      > [rt.jar:1.7.0_67]     at

      > javax.security.auth.login.LoginContext$4.run(LoginContext.java:690)

      > [rt.jar:1.7.0_67]     at

      > javax.security.auth.login.LoginContext$4.run(LoginContext.java:688)

      > [rt.jar:1.7.0_67]     at

      > java.security.AccessController.doPrivileged(Native Method)

      > [rt.jar:1.7.0_67]     at

      > javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:687)

      > [rt.jar:1.7.0_67]     at

      > javax.security.auth.login.LoginContext.login(LoginContext.java:595)

      > [rt.jar:1.7.0_67]     at

      > org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:675)

      > [hadoop-common-2.2.0.jar:]     ... 76 more

       

       

      Same happens on Linux machines except for it's UnixLoginModule it can't find.

       

       

      Actual exception happens on this line from org.apache.hadoop.hbase.security.User

       

          private SecureHadoopUser() throws IOException {

             ugi = UserGroupInformation.getCurrentUser();

          }

       

      Very simple EJB code illustrating the subject follows. It fails no matter HBase server exists or not.

       

          package hbasetest;

          import java.io.IOException;

          import javax.ejb.Stateless;

          import org.apache.hadoop.security.UserGroupInformation;

          @Stateless

          public class HbaseExecutorImpl implements HbaseExecutor {

              public void test() {

                  try {

                      UserGroupInformation ugi = UserGroupInformation.getCurrentUser();

                  } catch (IOException ex) {

                      throw new RuntimeException(ex);

                  }

              }

          }

       

      I've set up HBase client as a module, here's module.xml content

       

          <?xml version="1.0" encoding="UTF-8"?>

          <module xmlns="urn:jboss:module:1.3" name="com.something.hbaseclient">

              <resources>

                  <resource-root path="activation-1.1.jar"/>

                  <resource-root path="aopalliance-1.0.jar"/>

                  <resource-root path="asm-3.1.jar"/>

                  <resource-root path="avro-1.7.7.jar"/>

                  <resource-root path="commons-beanutils-1.7.0.jar"/>

                  <resource-root path="commons-beanutils-core-1.8.0.jar"/>

                  <resource-root path="commons-cli-1.2.jar"/>

                  <resource-root path="commons-codec-1.7.jar"/>

                  <resource-root path="commons-collections-3.2.1.jar"/>

                  <resource-root path="commons-compress-1.4.1.jar"/>

                  <resource-root path="commons-configuration-1.6.jar"/>

                  <resource-root path="commons-digester-1.8.jar"/>

                  <resource-root path="commons-httpclient-3.1.jar"/>

                  <resource-root path="commons-io-2.4.jar"/>

                  <resource-root path="commons-lang-2.6.jar"/>

                  <resource-root path="commons-logging-1.1.1.jar"/>

                  <resource-root path="commons-math-2.1.jar"/>

                  <resource-root path="commons-net-3.1.jar"/>

                  <resource-root path="findbugs-annotations-1.3.9-1.jar"/>

                  <resource-root path="guava-12.0.1.jar"/>

                  <resource-root path="guice-3.0.jar"/>

                  <resource-root path="guice-servlet-3.0.jar"/>

                  <resource-root path="hadoop-auth-2.2.0.jar"/>

                  <resource-root path="hadoop-common-2.2.0.jar"/>

                  <resource-root path="hadoop-mapreduce-client-core-2.2.0.jar"/>

                  <resource-root path="hadoop-yarn-api-2.2.0.jar"/>

                  <resource-root path="hadoop-yarn-common-2.2.0.jar"/>

                  <resource-root path="hbase-client-0.98.5-hadoop2.jar"/>

                  <resource-root path="hbase-common-0.98.5-hadoop2.jar"/>

                  <resource-root path="hbase-protocol-0.98.5-hadoop2.jar"/>

                  <resource-root path="htrace-core-2.04.jar"/>

                  <resource-root path="jackson-core-asl-1.8.8.jar"/>

                  <resource-root path="jackson-jaxrs-1.8.8.jar"/>

                  <resource-root path="jackson-mapper-asl-1.8.8.jar"/>

                  <resource-root path="jackson-xc-1.8.8.jar"/>

                  <resource-root path="javax.inject-1.jar"/>

                  <resource-root path="jaxb-api-2.2.2.jar"/>

                  <resource-root path="jaxb-impl-2.2.3-1.jar"/>

                  <resource-root path="jboss-ejb-api_3.2_spec-1.0.0.Final.jar"/>

                  <resource-root path="jersey-core-1.8.jar"/>

                  <resource-root path="jersey-guice-1.9.jar"/>

                  <resource-root path="jersey-json-1.8.jar"/>

                  <resource-root path="jersey-server-1.8.jar"/>

                  <resource-root path="jets3t-0.6.1.jar"/>

                  <resource-root path="jettison-1.3.1.jar"/>

                  <resource-root path="jetty-6.1.26.jar"/>

                  <resource-root path="jetty-util-6.1.26.jar"/>

                  <resource-root path="jsch-0.1.42.jar"/>

                  <resource-root path="jsr305-1.3.9.jar"/>

                  <resource-root path="log4j-1.2.17.jar"/>

                  <resource-root path="netty-3.6.6.Final.jar"/>

                  <resource-root path="paranamer-2.3.jar"/>

                  <resource-root path="protobuf-java-2.5.0.jar"/>

                  <resource-root path="slf4j-api-1.6.4.jar"/>

                  <resource-root path="slf4j-log4j12-1.6.4.jar"/>

                  <resource-root path="snappy-java-1.0.4.1.jar"/>

                  <resource-root path="xmlenc-0.52.jar"/>

                  <resource-root path="xz-1.0.jar"/>

                  <resource-root path="zookeeper-3.4.6.jar"/>

              </resources>

              <dependencies>

                  <module name="javaee.api"/>

              </dependencies>

          </module>

       

      jboss-deployment-structure.xml looks like this:

       

          <jboss-deployment-structure>

              <deployment>

                  <dependencies>

                      <module name="com.something.hbaseclient"/>

                  </dependencies>

              </deployment>

          </jboss-deployment-structure>

       

      I'd like to know what happens. It seems code residing on WildFly has wrong security context and hence some WildFly settings should be helpful but I really got no idea what to do for now.

       

      Any thoughts or advices would be greatly appreciated.

       

      Thanks in advance,

      Viktor