ibm-cloudmessage-hub

Kafka consumer init throws exception: Could not find a 'KafkaClient' entry


I have java class implementing Runnable and instantiating kafka consumer in bluemix. This class is throwing below exception when trying to instantiate KafkaConsumer. The jaas.conf file is stored in a shared directory. This was working fine for the past 1 month. It started throwing this error today. I do not remember making any changes to my code. I am using kafka-client 0.9.0.0. I also tried with kafka client 0.9.0.1 with same result.

org.apache.kafka.common.KafkaException: 
java.lang.IllegalArgumentException: Could not find a 
'KafkaClient' entry in `/home/vcap/app/wlp/usr/shared/config/lib
 /global/jaas.conf`. 

The file jaas.conf is present at the location it is looking for and has following content in it.

KafkaClient {
  com.ibm.messagehub.login.MessageHubLoginModule required
  serviceName="kafka"
  username="xxxxxxx"
  password="xxxxxxx"
};

Solution

  • Based on path of "jass.conf" file, I presume that you are running a Liberty app in Bluemix, If this is the case then you have to make sure to specify jaasLoginModule into server.xml as following:

    <featureManager>
       <feature>appSecurity-2.0</feature>
    </featureManager>
    
    <library id="messageHubLoginLib">
      <fileset dir="${server.config.dir}" includes="messagehub.login-1.0.0.jar"/>
    </library>
    
    <jaasLoginModule id="KafkaClient"
                className="com.ibm.messagehub.login.MessageHubLoginModule"
                controlFlag="REQUIRED" libraryRef="messageHubLoginLib">
       <options serviceName="kafka" username="#USERNAME" password="#PASSWORD"/>
    </jaasLoginModule>
    
    <jaasLoginContextEntry id="KafkaClient" name="KafkaClient" loginModuleRef="KafkaClient"  />
    

    Note: just for clarification, if you're using Liberty app in Bluemix then the current JAAS configuration is not using that jaas.conf file. Therefore must use server.xml configuration as described above.

    here's a link where you could find more info about how to configure Liberty