tracker issue : CF-4164063

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

OnMissing template not used in REST

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): / (Alexander Hass)

Created: 06/14/2016

Components: REST Services

Versions: 10.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: CF2016_Final /

Priority/Frequency: Normal / Few users will encounter

Locale/System: ALL / Win 2012 Server x64

Vote Count: 1

Listed in the version 2016.0.03.300466 Issues Fixed doc
Problem Description: I need to show a custom missing XML if someone access an invalid path in our REST service. We tried to add an OnMissing template that outputs a valid XML structure and not only a text "Not Found" that cannot parsed by XML parsers.

Steps to Reproduce: Run a missing REST function

Actual Result: non-XML structure text "Not Found"

Expected Result: Valid XML with error message, customizable by us.

Any Workarounds: None.

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

Watson Bug ID:	4164063

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

Attachments:

Comments:

<cffunction name="onMissingTemplate" output="false" returntype="void"> <cfthrow errorcode="404" message="Missing" /> </cffunction>
Comment by External U.
2402 | June 14, 2016 03:38:24 AM GMT
Moved to Paul !
Comment by Suresh J.
2403 | June 17, 2016 12:26:08 AM GMT
Comments from Paul We do not have such a feature. And it will not be possible to provide onMissingTemplate support. During REST service registration, we generate the JSR 311 annotated classes and provide it to Jersey. From these annotations, Jersey creates the Rules to identify which method in CFC should be invoked when a request is received. Only if the method is identified, we get the control from the jersey to create CFC instance and invoke the method. If the user is requesting an invalid URL, the request will fail at the Jersey level itself and we will not get the control to execute the onMissingTemplate.
Comment by Suresh J.
2404 | June 27, 2016 06:46:41 AM GMT
- Why is this possible with OnError, but not OnMissing? - Is there a way to configure this in Jersey? - Can you at least return valid XML, please?
Comment by External U.
2405 | June 27, 2016 07:47:14 AM GMT
Per https://jersey.java.net/apidocs/latest/jersey/index.html there is a NotFoundException.
Comment by External U.
2406 | June 27, 2016 07:52:28 AM GMT
We can try handling at Jersey .. moving the bug back for investigation !
Comment by Suresh J.
2407 | June 28, 2016 03:24:26 AM GMT
With the fix the REST Response would be sent as <REST><MESSAGE>Not Found</MESSAGE><STATUS>404</STATUS></REST> when the invalid URL is requested.
Comment by Krishna R.
2408 | September 02, 2016 06:59:14 AM GMT
That sounds like a working solution. Please do not forget to set the http status header 404.
Comment by External U.
2409 | September 02, 2016 11:19:52 AM GMT
Hi, We have included the fix for ColdFusion 2016. Do you want it to be included for ColdFusion 10 or 11 as well?
Comment by Krishna R.
2410 | October 18, 2016 10:56:26 PM GMT
No need for a backport for us. Thanks.
Comment by External U.
2411 | November 25, 2016 06:36:04 AM GMT
Thanks Alex!
Comment by HariKrishna K.
2412 | November 25, 2016 07:10:18 AM GMT
We just discussed this again and I learned that the current implemented solution is causing some issues. Sometimes we have JSON and sometimes XML reponses. I was not aware of this, but in case of a JSON request the responds should be JSON and not XML. Additionally the developer asked again if it may be possible to give this back to OnMissing Event handler so he has full controll and can also change the content of the response.
Comment by External U.
2413 | November 25, 2016 07:38:21 AM GMT