Loading

SFTP Connector Facing "java.lang.NullPointerException", "not able to execute CDW Operation" Exceptions

Fecha de publicación: Mar 4, 2025
Solución

SYMPTOM

After enabling DEBUG logs for SFTP connector and deploying the application, getting errors in application logs with below format,

2021-01-01 00:00:00,000 DEBUG o.m.t.s.SftpConnectionFactory [AsyncHttpClient-Callback] Successfully connected to: sftp://username:****@sftp.hosturi.com:22/Directory
2021-01-01 00:00:00,000 DEBUG o.m.t.s.SftpClient [AsyncHttpClient-Callback] Attempting to cwd to: /Directory
2021-01-01 00:00:00,000 ERROR o.m.t.s.SftpClient [AsyncHttpClient-Callback] Error 'The system cannot find the file specified. ' occurred when trying to CDW to '/Directory'.
2021-01-01 00:00:00,000 DEBUG o.m.t.s.SftpMessageReceiver [AsyncHttpClient-Callback] Unable to connect/reconnect to SFTP server sftp://username:****@sftp.hosturi.com:22/Directory
2021-01-01 00:00:00,000 ERROR o.m.r.n.ConnectNotifier [AsyncHttpClient-Callback] Failed to connect/reconnect: Trying to reconnect to SFTP server sftp://username:****@sftp.hosturi.com:22/Directory. Root Exception was: null. Type: class java.lang.NullPointerException

On Analysis of the DEBUG logs, you could see that the applicaiton is able to connect to the SFTP server, but not able to CDW to the required directory. 


CAUSE

Based on the SFTP Server settings, the commands executed from the client would be running either in the "home directory" or the "current directory" in which the client connection is established. Typically, when the commands are executed from the home directory, the application would find the required path. But in the later scenarios, the SFTP client might not find the required directory structure because the connection is already in a specific directory on an SFTP server. During the later scenarios, the application would face the following errors
 

SOLUTION

When Configuring the path for a connection in the SFTP server, always mention the path with "/~/" as a prefix. This would force the SFTP connection to go to the home directory before navigating to the actual path. This method would typically address the issue of "cannot find the file specified" errors in an SFTP Connection. 

Instead of "sftp://username:****@sftp.hosturi.com:22/Directory" Use "sftp://username:****@sftp.hosturi.com:22/~/Directory". 

The application configuration for inbound endpoint would look like below in Mule 3 for polling SFTP server setting,
<sftp:inbound-endpoint path="/~/Directory" 
 

Wiki Link for the "~" Operator is provided here
Número del artículo de conocimiento

001120563

 
Cargando
Salesforce Help | Article