tracker issue : CF-3346117

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

[ANeff] Bug for: restInitApplication("absolute path",..) null pointer in Application.cfc pseudo-constructor

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 10/14/2012

Components: REST Services

Versions: 10.0

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: Final /

Priority/Frequency: Minor / Very few users will encounter

Locale/System: English / Win All

Vote Count: 0

Listed in the version 2016.0.0.297996 Issues Fixed doc
restInitApplication("full absolute path",..) w/in Application.cfc's pseudo-constructor throws null pointer

Repro:

C:\inetpub\wwwroot\Application.cfc
----------------------------------
component {
  THIS.name = "TestRest";
  THIS.restSettings.skipCFCWithError = true;
  restInitApplication("C:\inetpub\wwwroot", "RestTest");
  //function onRequestStart() {restInitApplication("C:\inetpub\wwwroot", "RestTest"); return true;}
}

1) Create C:\inetpub\wwwroot\Application.cfc as per above
2) Browse to http://localhost and see exception (attached) and REST app is not registered in CF Admin
3) Comment out this line: restInitApplication("C:\inetpub\wwwroot", "RestTest");
4) Uncomment this line: function onRequestStart() {restInitApplication("C:\inetpub\wwwroot", "RestTest"); return true;}}
5) Browse to http://localhost and then see REST app is registered in CF Admin

RestInitApplication("full absolute path",..) should also work in the pseudo-constructor, or a better exception should be thrown. (ex: "RestInitApplication() is not allowed within Application.cfc's initialization code."). I only found this issue b/c I was testing REST. Most users will not run RestInitApplication() in Application.cfc's pseudo-constructor. Thus, I am fine w/ the current behavior - but the exception message should be helpful (not null pointer).

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

Watson Bug ID:	3346117

External Customer Info:
External Company:  
External Customer Name: itisdesign
External Customer Email:

Attachments:

  1. October 15, 2012 00:00:00: 1_20121014_RestInitApplicationThrowsNullPointer_Exception.txt

Comments:

It's _annoying_ that when the bugbase session times out, it discards any pending notes we've typed. I'll try to remember what I wrote.. On second thought, I'd keep current behavior but change the error message. Reason: b/c even RestInitApplication("/mymapping") (where "/mymapping" is defined in CF Admin AND in Application.cfc's pseudo-constructor) would cause confusion when ran within Application.cfc's pseudo-constructor if "/mymapping" was pre-defined to a different path via CF Admin. B/c within Application.cfc's pseudo-constructor, RestInitApplication("/mymapping") would still be using the path defined in CF Admin. So, yeah, just change the error message to be more helpful please. Ex: "RestInitApplication() is not allowed within Application.cfc's initialization code." The current Null Pointer message isn't helpful at all. Thanks!, -Aaron
Comment by External U.
17567 | October 14, 2012 03:40:22 PM GMT
Hmm, using restInitApplication() w/in onRequestStart() is problematic as well (code is above, in description). Even if no CFCs have been modified (including Application.cfc), calls to REST-enabled CFCs throw this exception: "Error","ajp-bio-8012-exec-3","10/15/12","02:04:49","TestRest","object is not an instance of declaring class The specific sequence of files included or processed is: C:\inetpub\wwwroot\Restservice.cfc'' " java.lang.IllegalArgumentException: object is not an instance of declaring class See? "TestRest" is the application's name (THIS.name="TestRest"). Thus, that exception is regarding Application.cfc itself. Shouldn't RestInitApplication() ignore Application.cfc files?
Comment by External U.
17568 | October 15, 2012 01:07:47 AM GMT
And, btw, the error that's logged to coldfusion-error.log is: SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container java.lang.IllegalArgumentException: object is not an instance of declaring class The error message in my previous post was from exception.log. Basically, user does not see a CF exception. User sees a web server exception. So these REST exceptions should probably be handled better.
Comment by External U.
17569 | October 15, 2012 01:21:37 AM GMT
I have checked this scenerio in CF10 update 11 and it seems to work fine: Following first 2 steps: No exception is thrown and the REST app is registered in CF Admin Can you please confirm (Comment added from ex-user id:nawani)
Comment by Adobe D.
17570 | September 17, 2013 11:48:16 PM GMT
Hi Anuj, Splendor Public Beta still throws Null Pointer exception. Steps to Reproduce: 1) Create C:\inetpub\wwwroot\Application.cfc having this: component { THIS.name = "TestRest"; THIS.restSettings.skipCFCWithError = true; restInitApplication("C:\inetpub\wwwroot", "RestTest"); } 2) Browse to: http://localhost 3) See Null Pointer exception is thrown and REST app is not registered in CF Admin Thanks!, -Aaron
Comment by External U.
17571 | February 28, 2014 12:53:50 AM GMT
Hi Anuj, This issue still exists in CF 11 Update 3 (11,0,03,292245(PreRelease)) on x64 Windows 8.1 Pro, using the repro code in my last comment (on 10:23:50 PM GMT+00:00 Feb 27, 2014). Using restInitApplication(expandPath("./"), "foo") in Application.cfc's pseudo constructor throws java.lang.NullPointerException. Thanks!, -Aaron
Comment by External U.
17572 | November 27, 2014 04:41:10 PM GMT
Using Enterprise edition, if that matters, w/ IIS.
Comment by External U.
17573 | November 27, 2014 04:42:30 PM GMT
Verified the bug, throws NPE. Marking it for "ToFix" for handling the NPE.
Comment by HariKrishna K.
17574 | December 09, 2014 05:25:46 AM GMT
If the Application.cfc conatins RESTInitApplication of the same appilcation in its pseudo constructor, the initialization was going to infinite loop causing the Application not fully initialized. So it is throwing NullPointerException on registration. Fixed the issue such that, if the same application is tried to initialize again, we are throwing exception.
Comment by Paul N.
17575 | September 25, 2015 06:00:02 AM GMT
Verified with the fix with the patch. Testcase is added at //depot/qa/cf/regression/coretests/restservices/RESTServices/bugCF-3346117/abc.cfm
Comment by HariKrishna K.
17576 | September 25, 2015 06:02:23 AM GMT