1
votes

I am having problems with my FTP endpoint. It will work for a little then stop working and give me hostname can't be null. I am using studio version: 3.4.0. My flow is up to the FTP is:

<context:property-placeholder location="environment.properties"/>
    <flow name="NpPlaFeedFlow1" doc:name="NpPlaFeedFlow1">
        <quartz:inbound-endpoint jobName="GetAttributes" cronExpression="30 * * * * ?" startDelay="500" responseTimeout="10000" doc:name="Quartz" repeatCount="0" repeatInterval="0">
            <quartz:event-generator-job/>
        </quartz:inbound-endpoint>
        <message-properties-transformer  doc:name="Message Properties" scope="session">
            <add-message-property key="database.server" value="${database.server}"/>
            <add-message-property key="database.port" value="${database.port}"/>
            <add-message-property key="database.user" value="${database.user}"/>
            <add-message-property key="database.password" value="${database.password}"/>
            <add-message-property key="database.databaseName" value="${database.databaseName}"/>
            <add-message-property key="adwords.promo" value="${adwords.promo}"/>
            <add-message-property key="file.fileName" value="${file.fileName}"/>
            <add-message-property key="ftp.serverName" value="${ftp.serverName}"/>
        </message-properties-transformer>
        <component doc:name="Java" class="com.newpig.transformer.GeneratePLA"/>
        <file:file-to-string-transformer doc:name="File to String"/>
        <logger message="Hostname is: ${ftp.serverName}" level="INFO" doc:name="Logger"/>
        <ftp:outbound-endpoint host="${ftp.serverName}" port="21" user="${ftp.user}" password="${ftp.pass}" responseTimeout="10000" doc:name="FTP"/>

When I run the application the logger spits out the correct hostname as you can see below.

2014-03-12 16:16:45,078 [[npplafeed].NpPlaFeedFlow1.stage1.02] INFO  org.mule.api.processor.LoggerMessageProcessor - Hostname is: cmsdev_steves
2014-03-12 16:16:45,092 [[npplafeed].connector.ftp.mule.default.dispatcher.01] INFO  org.mule.lifecycle.AbstractLifecycleManager - Initialising: 'connector.ftp.mule.default.dispatcher.1429708287'. Object is: FtpMessageDispatcher
2014-03-12 16:16:45,092 [[npplafeed].connector.ftp.mule.default.dispatcher.01] INFO  org.mule.lifecycle.AbstractLifecycleManager - Starting: 'connector.ftp.mule.default.dispatcher.1429708287'. Object is: FtpMessageDispatcher
2014-03-12 16:16:45,109 [[npplafeed].connector.ftp.mule.default.dispatcher.01] ERROR org.mule.exception.CatchMessagingExceptionStrategy - 
********************************************************************************
Message               : hostname can't be null (java.lang.IllegalArgumentException)
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. hostname can't be null (java.lang.IllegalArgumentException)
  java.net.InetSocketAddress:-1 (null)
2. hostname can't be null (java.lang.IllegalArgumentException) (org.mule.transport.ConnectException)
  org.mule.transport.ftp.FtpConnector:556 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/ConnectException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.IllegalArgumentException: hostname can't be null
    at java.net.InetSocketAddress.<init>(Unknown Source)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:176)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:268)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

2014-03-12 16:16:45,146 [[npplafeed].connector.smtp.mule.default.dispatcher.01] INFO  org.mule.transport.service.DefaultTransportServiceDescriptor - Loading default outbound transformer: org.mule.transport.email.transformers.ObjectToMimeMessage
2014-03-12 16:16:45,151 [[npplafeed].connector.smtp.mule.default.dispatcher.01] INFO  org.mule.lifecycle.AbstractLifecycleManager - Initialising: 'connector.smtp.mule.default.dispatcher.2029326140'. Object is: SmtpMessageDispatcher
2014-03-12 16:16:45,180 [[npplafeed].connector.smtp.mule.default.dispatcher.01] INFO  org.mule.lifecycle.AbstractLifecycleManager - Starting: 'connector.smtp.mule.default.dispatcher.2029326140'. Object is: SmtpMessageDispatcher

Does anyone know what else to check? I have tried replacing host="${ftp.serverName}" with host="cmsdev-steves" and sometimes I can get it to work and sometimes not.

Edit I failed to mention in the original post that I have not been able to get the FTP component to connect at all using the variable. Originally I only had ftp.serverName in my properties file and didn't add it to the message-properties-transformer. I added it to that transformer in hopes that it would pick it up. Again, the logger spits out the right value so I can't see why the FTP endpoint doesn't also get the same value.

1
The "sometimes works, sometimes doesn't" is the scary part. I've never seen such an erratic behaviour. Are you sure you weren't running several instances of different versions of your app? - David Dossot
Yes David, that is what really bothers me as well. Sometimes closing and restarting mulestudio fixes the problem. See my edit above. It just seems odd that the FTP component will pick up the user and pass ok but not the hostname. - SteveS
Have you tried running on Mule instead of inside Studio? I can't fathom why properties replacement doesn't work for you, it just doesn't make sense :''( - David Dossot
Well, this is rather embarrassing but it turns out that the configuration file had an underscore in the host name. When I manually typed it into the FTP endpoint I correctly typed a dash. When I corrected the property file it worked. I wish it had responded "host unknown" rather than "null hostname". Thank you all for your time looking at this even though it was UE. - SteveS
Ah, at least it makes sense now :) - David Dossot

1 Answers

0
votes

The problem is that you are configuring your ftp credentials in the outbound endpoint.

Define a connector and put your ftp configuration (hostname, username and password) there instead.