Fix for org.apache.kafka.common.KafkaException: javax.security.auth.login.LoginException: unable to find LoginModule class
This commit is contained in:
		
							parent
							
								
									addfaa60a4
								
							
						
					
					
						commit
						acc9257af7
					
				@ -55,6 +55,10 @@ public class TbKafkaProducerTemplate<T extends TbQueueMsg> implements TbQueuePro
 | 
			
		||||
 | 
			
		||||
    @Builder
 | 
			
		||||
    private TbKafkaProducerTemplate(TbKafkaSettings settings, String defaultTopic, String clientId, TbQueueAdmin admin) {
 | 
			
		||||
        // Ugly workaround to fix org.apache.kafka.common.KafkaException: javax.security.auth.login.LoginException: unable to find LoginModule class
 | 
			
		||||
        // details: https://stackoverflow.com/questions/57574901/kafka-java-client-classloader-doesnt-find-sasl-scram-login-class
 | 
			
		||||
        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 | 
			
		||||
 | 
			
		||||
        Properties props = settings.toProducerProps();
 | 
			
		||||
 | 
			
		||||
        if (!StringUtils.isEmpty(clientId)) {
 | 
			
		||||
 | 
			
		||||
@ -71,6 +71,10 @@ public class TbKafkaNode implements TbNode {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
 | 
			
		||||
        // Ugly workaround to fix org.apache.kafka.common.KafkaException: javax.security.auth.login.LoginException: unable to find LoginModule class
 | 
			
		||||
        // details: https://stackoverflow.com/questions/57574901/kafka-java-client-classloader-doesnt-find-sasl-scram-login-class
 | 
			
		||||
        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 | 
			
		||||
 | 
			
		||||
        this.config = TbNodeUtils.convert(configuration, TbKafkaNodeConfiguration.class);
 | 
			
		||||
        Properties properties = new Properties();
 | 
			
		||||
        properties.put(ProducerConfig.CLIENT_ID_CONFIG, "producer-tb-kafka-node-" + ctx.getSelfId().getId().toString() + "-" + ctx.getServiceId());
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user