Jump to content
We've recently updated our Privacy Statement, available here ×
  • Debugging an FTP Connection for scheduled report jobs


    vchiem
    • Features: Logging, Scheduler Version: v7 Product: JasperReports® Server

    Issue:

    TIBCO JasperReports® Server allows report jobs to be scheduled to an FTP Server as an output destination. 

    How to best debug an FTP connection issues upon encountering any errors with the scheduled jobs? 

    One such use case is when users are able to configure scheduled report jobs with multiple FTP connections connecting to different FTP Servers. 

    The standard set of logging components does not log the ip address to be able to track which FTP Server the connection was made. 

    Are there any additional logging that can be set to generate further debugging information ? 

     


     

    Solution:

    In the "Output Options" page, there is a "Test Connection" button that can test for connection failures. 

    Below are the typical errors that can be generated in the ../WEB-INF/logs/jasperserver.log upon clicking on "Test Connection" :

    2020-06-12T11:19:20,472 ERROR SecureExceptionHandlerImpl,http-nio-8080-exec-4:116 - Auth fail
    
    2020-06-12T11:20:28,072 ERROR SecureExceptionHandlerImpl,http-nio-8080-exec-3:116 - No such file
    
    2020-06-12T11:24:07,180 ERROR SecureExceptionHandlerImpl,http-nio-8080-exec-2:116 - java.net.ConnectException: Connection refused: connect
    
    2020-06-12T11:28:14,744 ERROR SecureExceptionHandlerImpl,http-nio-8080-exec-4:116 - java.net.UnknownHostException: 172.17.18.6767

    The conditions for when the above errors would be generated are:

    • When directory is invalid, the "No such file" error 
    • When username or password is invalid, the "Auth fail" error
    • When port is invalid, the "Connection refused: connect" error 
    • When server address is invalid, the "java.net.UnknownHostException"

    For further debugging to be logged, the following logger component can be manually added to the "Server Settings" -> "Log Settings" to log extra FTP specific debug information (such as IP address) to the jasperserver.log:

    com.jaspersoft.jasperserver.api.engine.common.util.impl.FTPUtil

    An example is when the connection is successful it logs the IP and further DEBUG messages following the successful connection:

    2021-05-18T19:27:28,273 DEBUG FTPUtil,JasperServerScheduler_Worker-2:236 - FTP: connected to 172.17.18.204 LOGIN OK.
    2021-05-18T19:27:28,274 DEBUG FTPUtil,JasperServerScheduler_Worker-2:246 - Connected to 172.17.18.204 REPLY OK.

    For multiple FTP Servers, this extra level of information would be handy to know which FTP Server a report job was connected to.

    The debug information is based on specific conditions written inside the class, com.jaspersoft.jasperserver.api.engine.common.util.impl.FTPUtil (packaged inside ..WEB-INFlibjasperserver-api-engine-impl-7.9.0.jar). 

    An extract of the code is pasted below:

    public class FTPServiceClientImpl
    implements FTPService.FTPServiceClient
    {
    private FTPClient ftpClient = null;
    
    public FTPServiceClientImpl(String host, int port, String userName, String password)
    throws Exception
    {
    this.ftpClient = new FTPClient();
    this.ftpClient.connect(host, port);
    if (!this.ftpClient.login(userName, password))
    {
    this.ftpClient.logout();
    throw new JSException("FTP: Fail to login: may due to invalid username/ password.");
    }
    if (FTPUtil.log.isDebugEnabled()) {
    FTPUtil.log.debug("FTP: connected to " + host + " LOGIN OK.");
    }
    int reply = this.ftpClient.getReplyCode();
    if (!FTPReply.isPositiveCompletion(reply))
    {
    this.ftpClient.disconnect();
    throw new JSException("FTP: unable to connect to " + host);
    }
    if (FTPUtil.log.isDebugEnabled()) {
    FTPUtil.log.debug("Connected to " + host + " REPLY OK.");
    }
    this.ftpClient.enterLocalPassiveMode();

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...