JBOSS 给出 org.apache.kafka.common.KafkaException: auth.conf cannot be read
Posted
技术标签:
【中文标题】JBOSS 给出 org.apache.kafka.common.KafkaException: auth.conf cannot be read【英文标题】:JBOSS gives org.apache.kafka.common.KafkaException: auth.conf cannot be read 【发布时间】:2016-08-14 03:33:20 【问题描述】:当我在 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)
【问题讨论】:
可能您的 Wildfly 安装已损坏,或者您可能有一些权限问题。您是否尝试重新安装它,可能在另一个驱动器/设备上 【参考方案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 来模仿 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
【讨论】:
【参考方案2】:有一个名为 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 中进行了描述。
【讨论】:
以上是关于JBOSS 给出 org.apache.kafka.common.KafkaException: auth.conf cannot be read的主要内容,如果未能解决你的问题,请参考以下文章
org.apache.kafka.common.KafkaException: 无法构造 kafka 消费者
Kafka Producer - org.apache.kafka.common.serialization.StringSerializer 找不到
Flink实战系列Lorg/apache/flink/kafka/shaded/org/apache/kafka/clients/consumer/ConsumerRecord;)Ljava/
如何摆脱 NoSuchMethodError:Spark Streaming + Kafka 中的 org.apache.kafka.clients.consumer.KafkaConsumer.su
Kafka 错误:无法找到或加载主类 org.apache.kafka.clients.tools.ProducerPerformance
错误:值 toDF 不是 org.apache.spark.rdd.RDD[org.apache.kafka.clients.consumer.ConsumerRecord[String,String