JBOSS给出org.apache.kafka.common.KafkaException:无法读取auth.conf

时间:2016-04-21 06:11:20

标签: jboss apache-kafka wildfly kafka-consumer-api wildfly-10

当我在wildfly v 10中部署我的简单kafka项目的战争(在jar中工作得很好)时,我得到一些zookeeper连接异常[1]。这发生在kafka监听器开始与zookeeper连接时

[1]]

15:21:58,531 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 82) MSC000001: Failed to start service jboss.deployment.unit."ratha.war".component.KafkaServiceBean.START: org.jboss.msc.service.StartException in service jboss.deployment.unit."ratha.war".component.KafkaServiceBean.START: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
    at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:57)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
    at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)
    at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134)
    at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:88)
    at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:124)
    at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:138)
    at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54)
    ... 6 more
Caused by: javax.ejb.EJBException: org.apache.kafka.common.KafkaException: File jar:file:/Users/ratha/projects/wildfly-10.0.0.Final/modules/system/layers/base/org/picketbox/main/picketbox-4.9.4.Final.jar!/auth.confcannot be read.
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:187)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:349)
    at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:66)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
    at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
    at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
    at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
    at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
    at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
    at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
    at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161)
    ... 11 more
Caused by: org.apache.kafka.common.KafkaException: File jar:file:/Users/ratha/projects/wildfly-10.0.0.Final/modules/system/layers/base/org/picketbox/main/picketbox-4.9.4.Final.jar!/auth.confcannot be read.
    at org.apache.kafka.common.security.JaasUtils.isZkSecurityEnabled(JaasUtils.java:95)
    at kafka.consumer.ZookeeperConsumerConnector.connectZk(ZookeeperConsumerConnector.scala:184)
    at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:129)
    at kafka.javaapi.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:66)
    at kafka.javaapi.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:69)
    at kafka.consumer.Consumer$.createJavaConsumerConnector(ConsumerConnector.scala:120)
    at kafka.consumer.Consumer.createJavaConsumerConnector(ConsumerConnector.scala)

2 个答案:

答案 0 :(得分:1)

错误是由Kafka中的以下代码引起的

String loginConfigFile = System.getProperty(JAVA_LOGIN_CONFIG_PARAM);
if (loginConfigFile != null && loginConfigFile.length() > 0) {
        File configFile = new File(loginConfigFile);
        if (!configFile.canRead()) {
            throw new KafkaException("File " + loginConfigFile + "cannot be read.");
        }
...

在Wildfly 10中,JAVAX_LOGIN_CONFIG PARAM(java.security.auth.login.config)的属性设置为jar:file:/opt/jboss/wildfly/modules/system/layers/base/org/picketbox/main/picketbox-4.9.4.Final.jar!/auth.conf

在Wildfly 9中,上述属性为null。因此,快速解决方法是通过将该属性设置为null来模仿Wildfly 9。

为此,请使用-Djava.security.auth.login.config=选项修改standalone.conf,即。空值。我的standalone.conf将如下所示:

if [ "x$JAVA_OPTS" = "x" ]; then
    JAVA_OPTS="-Xms2048m -Xmx2048m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
    JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true -Djava.security.auth.login.config="
else
    echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi

答案 1 :(得分:0)

有一个名为 zookeeper.sasl.client 的属性,默认为 true,这意味着启用了 SASL 身份验证。如果我们需要 SASL 身份验证,则必须进行更多配置。如果不需要,那么我们可以通过将此属性设置为 false 来简单地禁用 SASL 身份验证。

System.setProperty("zookeeper.sasl.client", "false"); 

“客户端配置参数”部分下的 https://zookeeper.apache.org/doc/r3.5.2-alpha/zookeeperProgrammers.html 对此进行了描述。