Skip to main content
Inspiring
September 28, 2022
Answered

SMS Gateway Instance Won't Start on New CF21 Install

  • September 28, 2022
  • 3 replies
  • 567 views

Hello,

I am wondering if anyone could point me in the right direction. I am moving to a new Windows server and upgrading from CF2016 to CF2021, and I can't seem to get my SMS gateway running even though it works fine on the old server.

 

The errors I am getting in my coldfusion-out log when it attempts to start the instance are:
"SMSGateway (SMSWatch) Binding to SMSC"
"SMSGateway (SMSWatch) Bind operation failed: java.lang.NullPointerException"


This is the code for the CFC I am using for my instance. I am not sure where it originally came from, but probably from a ColdFusion example:

<cfcomponent>

	<cfset undeliverablePath = "C:\CF21\cfusion\sms\undeliverable" />
	
	<cffunction name="send" output="false" access="private" returntype="boolean">
		<cfargument name="username" required="true" type="string"/>
		<cfargument name="password" required="true" type="string"/>
		<cfargument name="from" required="true" type="string"/>
		<cfargument name="to" required="true" type="string"/>
		<cfargument name="body" required="true" type="string"/>
		
		<cftry>
			<!--- SMS can only be 160 characters. If SMS is longer than 160, break into multiple SMS's --->
			<cfset smsArray = arraynew(1)/>
			<cfset smsstr = ""/>
			<cfloop from="1" to="#len(arguments.body)#" index="i">
				<cfset smsstr = smsstr & mid(arguments.body, i, 1)/>
				
				<cfif i mod 160 eq 0>
					<cfset arrayappend(smsArray, smsstr)/>
					<cfset smsstr = ""/>
				</cfif>
			</cfloop>
			
			<cfif len(smsstr)>
				<cfset arrayappend(smsArray, smsstr)/>
			</cfif>
			
			<cfset urlstr = "https://api.twilio.com/2010-04-01/Accounts/#arguments.username#/SMS/Messages.xml"/>
			<cfloop from="1" to="#arraylen(smsArray)#" index="i">
				<cfhttp url="#urlstr#" method="post" username="#arguments.username#" password="#arguments.password#">
					<cfhttpparam type="formfield" name="From" value="#arguments.from#"/>
					<cfhttpparam type="formfield" name="To" value="#arguments.to#"/>
					<cfhttpparam type="formfield" name="Body" value="#smsArray[i]#"/>
				</cfhttp>
				
				<cfif listfirst(cfhttp.statusCode, " ") eq 200>
					<cflog file="sms-watcher-sent" text="from=#arguments.from#, to=#arguments.to#, body=#arguments.body#" />
					<cfreturn true/>
				<cfelse>
					<cfset twilXml = xmlparse(cfhttp.filecontent)/>
					<cflog file="sms-watcher-sent" text="error=#twilXml.TwilioResponse.RestException.Message.xmltext#" />
					<cfreturn false/>
				</cfif>
			</cfloop>
			
			<cfcatch type="any">
				<cflog file="sms-watcher" text="#cfcatch.message#" />
				<cfreturn false/>
			</cfcatch>
		</cftry>
	</cffunction>
	
 	<cffunction name="onAdd" access="public" output="false" returntype="void">
	 	<cfargument name="CFEvent" type="struct" required="yes">
		 
		 <cftry>
			<cffile action="read" file="#arguments.cfevent.data.filename#" variable="ddx" />
			<cfwddx action="wddx2cfml" input="#ddx#" output="smsStruct" />
			 
			<cfset fileName = getfilefrompath(arguments.cfevent.data.filename)/>
			<cfset folderName = getdirectoryfrompath(arguments.cfevent.data.filename)/>
			
			<cffile action="move" destination="#folderName#\#listfirst(fileName, ".")#.proc" source="#arguments.cfevent.data.filename#" />
			<cfset bSend = send(smsStruct.username, smsStruct.password, smsStruct.from, smsStruct.to, smsStruct.body)/>
			
			<cfif bSend>
	 			<cffile action="delete" file="#folderName#\#listfirst(fileName, ".")#.proc" />
			<cfelse>
				<cffile action="move" destination="#undeliverablePath#\#listfirst(fileName, ".")#.sms" source="#folderName#\#listfirst(fileName, ".")#.proc" />
			</cfif>
			
			<cfcatch type="any">
				  <cflog file="sms-watcher" text="#cfcatch.message#" />
				  <cffile action="move" destination="#undeliverablePath#\#listfirst(fileName, ".")#.sms" source="#folderName#\#listfirst(fileName, ".")#.proc" />
			</cfcatch>
		 </cftry>
    </cffunction>
 
    <cffunction name="onChange" access="public" output="false" returntype="void">
    </cffunction>
 
    <cffunction name="onDelete" access="public" output="false" returntype="void">
    </cffunction>
</cfcomponent>

 and here is the Config file:

directory=C:\CF21\cfusion\sms\spool
recurse=no
extensions=sms
interval=15000
addFunction=onAdd
changeFunction=onChange
deleteFunction=onDelete

 I feel clueless on this one, so it may be something obvious. Thank you in advance!

Correct answer BKBK

How did you get this to work in an earlier version. What steps did you follow in writing and configuring the CFC and the configuration file? Please share the steps in detail to help us understand.

 

I ask because your CFC is different from what I would expect. For example, it contains no onIncomingMessage method. In addition, your config file is different from the sample that ships with ColdFusion, C:\ColdFusion2021\cfusion\gateway\config\sms-test.cfg

3 replies

New Participant
October 10, 2025

I ran into a similar problem and ended up using sms.to to handle messaging instead. It let me skip the ColdFusion SMS gateway setup altogether. You just call their API from your code, and it worked right out of the box for me. Was way easier than messing with the built-in gateway that wouldn't start.

BKBK
Adobe Expert
October 11, 2025

Thanks for that, @charlotte_5275 . Sounds like a good solution.

New Participant
September 24, 2025

I see it's been a while since you posted, but I just wanted to ask if you ever got the SMS gateway to start properly. I’m running into a similar hiccup on CF2021 and wondering if anyone has tried tweaking JVM arguments or checking the logs for more clues. Would be great to hear if you found a workaround or if the CF update fixed it.

BKBK
Adobe Expert
September 24, 2025

@charlotte_5275 , we might be able to offer you suggestions. To do so, we have to know your situation.

 

Have you attempted to run the SMS gateway? If so, what "hiccups" are you running into?

BKBK
BKBKCorrect answer
Adobe Expert
September 28, 2022

How did you get this to work in an earlier version. What steps did you follow in writing and configuring the CFC and the configuration file? Please share the steps in detail to help us understand.

 

I ask because your CFC is different from what I would expect. For example, it contains no onIncomingMessage method. In addition, your config file is different from the sample that ships with ColdFusion, C:\ColdFusion2021\cfusion\gateway\config\sms-test.cfg

ebcohenAuthor
Inspiring
September 28, 2022

Thanks BKBK. You gave me the clue to find the file I needed.

BKBK
Adobe Expert
October 3, 2022

No problem. Feel free to open any further discussions on the subject. 🙂