<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question NIfi:  javax.security.auth.login.LoginException: No LoginModule found for org.apache.kafka.common.security.plain.PlainLoginModule Error in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/NIfi-javax-security-auth-login-LoginException-No-LoginModule/m-p/398909#M250339</link>
    <description>&lt;P&gt;Hi Team, I am implementing the CSFLE(Client Side Field Level Encryption) in the Nifi for the Kafka data. I have written Groovy script to get the logic like Consume/deserialize/Encrypt the data. The script is working as standalone. However, if i place it in ExecuteScript processor ,i am getting Caused by:&lt;STRONG&gt; javax.security.auth.login.LoginException: No LoginModule found for org.apache.kafka.common.security.plain.PlainLoginModule Error.&lt;/STRONG&gt; It seems it is compatibility issue in the kafka-client jar file. However, i could not find the fix. Please provide your input on this.&lt;/P&gt;&lt;P&gt;My groovy script is below.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;import org.apache.kafka.clients.consumer.ConsumerRecord
import org.apache.kafka.clients.consumer.ConsumerRecords
import org.apache.kafka.clients.consumer.KafkaConsumer
import org.apache.kafka.common.serialization.StringDeserializer
import java.time.Duration
import org.apache.kafka.common.security.plain.PlainLoginModule
import javax.security.auth.login.Configuration
import javax.security.auth.login.AppConfigurationEntry
import javax.security.auth.login.LoginContext


Thread.currentThread().setContextClassLoader(null);
def kafkaConsumer = null
try {
    // Kafka consumer properties
    def props = [
        'bootstrap.servers'                    : 'server:port',
        'auto.register.schemas'                : 'false',
        'basic.auth.credentials.source'        : 'USER_INFO',
		'key.serializer'                       : 'org.apache.kafka.common.serialization.StringSerializer',
        'value.serializer'                     : 'io.confluent.kafka.serializers.KafkaAvroSerializer',
        'key.deserializer'                     : 'org.apache.kafka.common.serialization.StringDeserializer',
        'value.deserializer'                   : 'io.confluent.kafka.serializers.KafkaAvroDeserializer',
        'security.protocol'                    : 'SASL_SSL',
        'schema.registry.url'                  : 'Sampe-urlcloud',
        'basic.auth.user.info'                 : 'unamee:pass',
        'sasl.mechanism'                       : 'PLAIN',
        'sasl.jaas.config'                     : 'org.apache.kafka.common.security.plain.PlainLoginModule required username="uname" password="pass";',
        'use.latest.version'                   : 'false',
        'client.id'                            : 'csfle-simple-producer',
        'auto.offset.reset'                    : 'earliest',
        'group.id'                             : 'nifi-csfle-group6',
        'rule.executors._default_.param.access.key.id' :'keyid',
        'rule.executors._default_.param.secret.access.key' : 'accesskey'
    ]
    log.info("RAJIV-1: 'csfle_test_kek_oct_29'")
    // Create KafkaConsumer instance
    kafkaConsumer = new KafkaConsumer&amp;lt;String, Object&amp;gt;(props)
	log.info("RAJIV-2: 'csfle_test_kek_oct_29'")
    kafkaConsumer.subscribe(['csfle_test_kek_oct_29'])
	log.info("RAJIV-3: 'csfle_test_kek_oct_29'")

    // Poll for messages
    ConsumerRecords&amp;lt;String, Object&amp;gt; records = kafkaConsumer.poll(Duration.ofSeconds(10))

    if (records.isEmpty()) {
        log.info("No records found in the topic.")
    } else {
        // Process each record
        records.each { ConsumerRecord&amp;lt;String, Object&amp;gt; record -&amp;gt;
            try {
                // Log the record details
                log.info("Received record: Topic=${record.topic()}, Partition=${record.partition()}, Offset=${record.offset()}, Key=${record.key()}, Value=${record.value()}")
            } catch (Exception e) {
                log.error("Error processing record: ${e.getMessage()}")
            }
        }
    }
} catch (Exception e) {
   log.error("Kafka Consumer Error: ${e.message}", e)

} finally {
    // Close the Kafka consumer
    if (kafkaConsumer != null) {
        kafkaConsumer.close()
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2024 07:11:30 GMT</pubDate>
    <dc:creator>rajivswe_2k7</dc:creator>
    <dc:date>2024-12-16T07:11:30Z</dc:date>
    <item>
      <title>NIfi:  javax.security.auth.login.LoginException: No LoginModule found for org.apache.kafka.common.security.plain.PlainLoginModule Error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NIfi-javax-security-auth-login-LoginException-No-LoginModule/m-p/398909#M250339</link>
      <description>&lt;P&gt;Hi Team, I am implementing the CSFLE(Client Side Field Level Encryption) in the Nifi for the Kafka data. I have written Groovy script to get the logic like Consume/deserialize/Encrypt the data. The script is working as standalone. However, if i place it in ExecuteScript processor ,i am getting Caused by:&lt;STRONG&gt; javax.security.auth.login.LoginException: No LoginModule found for org.apache.kafka.common.security.plain.PlainLoginModule Error.&lt;/STRONG&gt; It seems it is compatibility issue in the kafka-client jar file. However, i could not find the fix. Please provide your input on this.&lt;/P&gt;&lt;P&gt;My groovy script is below.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;import org.apache.kafka.clients.consumer.ConsumerRecord
import org.apache.kafka.clients.consumer.ConsumerRecords
import org.apache.kafka.clients.consumer.KafkaConsumer
import org.apache.kafka.common.serialization.StringDeserializer
import java.time.Duration
import org.apache.kafka.common.security.plain.PlainLoginModule
import javax.security.auth.login.Configuration
import javax.security.auth.login.AppConfigurationEntry
import javax.security.auth.login.LoginContext


Thread.currentThread().setContextClassLoader(null);
def kafkaConsumer = null
try {
    // Kafka consumer properties
    def props = [
        'bootstrap.servers'                    : 'server:port',
        'auto.register.schemas'                : 'false',
        'basic.auth.credentials.source'        : 'USER_INFO',
		'key.serializer'                       : 'org.apache.kafka.common.serialization.StringSerializer',
        'value.serializer'                     : 'io.confluent.kafka.serializers.KafkaAvroSerializer',
        'key.deserializer'                     : 'org.apache.kafka.common.serialization.StringDeserializer',
        'value.deserializer'                   : 'io.confluent.kafka.serializers.KafkaAvroDeserializer',
        'security.protocol'                    : 'SASL_SSL',
        'schema.registry.url'                  : 'Sampe-urlcloud',
        'basic.auth.user.info'                 : 'unamee:pass',
        'sasl.mechanism'                       : 'PLAIN',
        'sasl.jaas.config'                     : 'org.apache.kafka.common.security.plain.PlainLoginModule required username="uname" password="pass";',
        'use.latest.version'                   : 'false',
        'client.id'                            : 'csfle-simple-producer',
        'auto.offset.reset'                    : 'earliest',
        'group.id'                             : 'nifi-csfle-group6',
        'rule.executors._default_.param.access.key.id' :'keyid',
        'rule.executors._default_.param.secret.access.key' : 'accesskey'
    ]
    log.info("RAJIV-1: 'csfle_test_kek_oct_29'")
    // Create KafkaConsumer instance
    kafkaConsumer = new KafkaConsumer&amp;lt;String, Object&amp;gt;(props)
	log.info("RAJIV-2: 'csfle_test_kek_oct_29'")
    kafkaConsumer.subscribe(['csfle_test_kek_oct_29'])
	log.info("RAJIV-3: 'csfle_test_kek_oct_29'")

    // Poll for messages
    ConsumerRecords&amp;lt;String, Object&amp;gt; records = kafkaConsumer.poll(Duration.ofSeconds(10))

    if (records.isEmpty()) {
        log.info("No records found in the topic.")
    } else {
        // Process each record
        records.each { ConsumerRecord&amp;lt;String, Object&amp;gt; record -&amp;gt;
            try {
                // Log the record details
                log.info("Received record: Topic=${record.topic()}, Partition=${record.partition()}, Offset=${record.offset()}, Key=${record.key()}, Value=${record.value()}")
            } catch (Exception e) {
                log.error("Error processing record: ${e.getMessage()}")
            }
        }
    }
} catch (Exception e) {
   log.error("Kafka Consumer Error: ${e.message}", e)

} finally {
    // Close the Kafka consumer
    if (kafkaConsumer != null) {
        kafkaConsumer.close()
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 07:11:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NIfi-javax-security-auth-login-LoginException-No-LoginModule/m-p/398909#M250339</guid>
      <dc:creator>rajivswe_2k7</dc:creator>
      <dc:date>2024-12-16T07:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: NIfi:  javax.security.auth.login.LoginException: No LoginModule found for org.apache.kafka.common.security.plain.PlainLoginModule Error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NIfi-javax-security-auth-login-LoginException-No-LoginModule/m-p/398923#M250342</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/51895"&gt;@rajivswe_2k7&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;Is it possible that you are not specifying the path In "Module Directory"&amp;nbsp; property of the ExecuteScript Processor where all required dependencies can be located?&lt;/P&gt;&lt;P&gt;Also my understanding that the script in such processor is evaluated on each flowfile so if&amp;nbsp; you are running complex code that requires a lot of external dependencies this could be costly. A cleaner and more efficient way is to create custom processor where all the code and dependencies gets packaged as NAR file, or if you are using version 2.0 you can create custom processor using python extensions if the same thing can be implemented in python.&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 12:38:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NIfi-javax-security-auth-login-LoginException-No-LoginModule/m-p/398923#M250342</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2024-12-16T12:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: NIfi:  javax.security.auth.login.LoginException: No LoginModule found for org.apache.kafka.common.security.plain.PlainLoginModule Error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NIfi-javax-security-auth-login-LoginException-No-LoginModule/m-p/398973#M250350</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;. This is the issue, if i specify the external&amp;nbsp;&lt;SPAN&gt;"Module Directory"&amp;nbsp; in the executescript , the ClassLoader somewhat clashed and no required class get loaded. So i have removed that and placed all my Jars into nifi/lib directory alone. Now it is working fine. Please let me know if any better way to handle that. Just not to use the nifi/lib directory.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, let me try creating the custom processors to achieve this CSFLE.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2024 10:27:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NIfi-javax-security-auth-login-LoginException-No-LoginModule/m-p/398973#M250350</guid>
      <dc:creator>rajivswe_2k7</dc:creator>
      <dc:date>2024-12-17T10:27:43Z</dc:date>
    </item>
  </channel>
</rss>

