tracker issue : CF-3375263

select a category, or use search below
(searches all categories and all time range)
Title:

Misleading error with REST services and missing returnType

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Raymond Camden / Raymond Camden (Raymond Camden)

Created: 11/30/2012

Components: REST Services

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final / 287369

Priority/Frequency: Normal / Few users will encounter

Locale/System: English / Windows 7 64-bit

Vote Count: 0

Given this CFC:

<cfcomponent rest="true" restPath="timeService">

	<cffunction name="sayHello" access="remote" httpMethod="get">
		<cfreturn dateTimeFormat(now())>
	</cffunction>

</cfcomponent>

I was not able to call it via REST. When I did, I got a service not found error. Turns out the issue was a missing returnType. As soon as I added that...

<cfcomponent rest="true" restPath="timeService">

	<cffunction name="sayHello" access="remote" httpMethod="get" returnType="string">
		<cfreturn dateTimeFormat(now())>
	</cffunction>

</cfcomponent>

it worked. CF should have thrown an error here instead of a service not found result. I'll certainly take the blame for forgetting a returnType, but if it is required, then it should be required. Note that the docs only say access="remote" is required, it does not mention returnType being required (as far as I can see).

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3375263

Deployment Phase:	Release Candidate

External Customer Info:
External Company:  
External Customer Name: cfjedimaster
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

Have tested this in CF10 Update 8 and update 11 When we create a rest service component as below: <cfcomponent rest="true" restPath="timeService"> <cffunction name="sayHello" access="remote" httpMethod="get"> <cfreturn dateTimeFormat(now())> </cffunction> </cfcomponent>, while registering the service through CF Admin page, it gives error and doesn't allow user to add the service. The error says: Application map2 could not be initialized. Reason: The application does not contain any rest enabled CFCs. The application does not contain any rest enabled CFCs. When we go to exception.log file it states the reason: returnType must be defined for remote CFC functions. Please let us know the steps to repro this scenerio. (Comment added from ex-user id:nawani)
Comment by Adobe D.
17065 | September 17, 2013 04:29:12 AM GMT
In my opinion, you just did create a repro. The CF Admin said that you do not have a REST enabled CFC. I think we can agree that is wrong. You do. You just happen to have one with an error. Why would I go look in the exception.log when the error implies something else - like maybe I picked the wrong folder?
Comment by External U.
17066 | September 17, 2013 08:32:27 AM GMT
There is a flag called "skipcfcwitherror". You can set that in the Application.cfc. The default value for this setting is false. i.e., we will stop scanning when ever there is an error in the CFC. In this case, we will propagate the exception to the admin, when registering a service. But if the "skipcfcwitherror" is specified as true, then we will not throw the exception to the admin, instead we will continue to check other CFCs. The user has to look into the log files for particular errors with the CFCs. In case, the user has specified "skipcfcwitherror" as true and all his CFCs in the application has some errors, then we will log these error messages and continue with the next CFC. Since all the CFCs are having errors, all these errors will be logged in to the log file. But at last, there there are no REST enabled CFCs, that can be registered as a service. In this case, we will throw Exception that there are no REST enabled CFCs in the application.
Comment by Paul N.
17067 | December 11, 2013 09:51:48 AM GMT
I've got a folder with App.cfc using skipcfcwitherror=false. I put the CFC above in it, the fixed one, and loaded it in the admin. I hit the REST CFC and confirmed. I then 'broke' the CFC by removing the returntype. When I try to hit it I get an error. But in the admin I can reload the service mapping and it does NOT say an error occurred.
Comment by External U.
17068 | December 11, 2013 10:02:27 AM GMT
This bug is fixed. Perforce location: C:\perforce_New\ColdFusion\qa\cf\regression\newmanual\REST\Bugs\CF-3375263 (Comment added from ex-user id:nawani)
Comment by Adobe D.
17069 | December 18, 2013 04:05:28 AM GMT