• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Registering REST service error

Engaged ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

CF2016 (OSX 10.11.6)

In the CF Admin (Data & Services > REST Services I'm trying to register a REST service. When I select the path to the folder where my 3 test files live (all 3 files are in the same folder) and attempt to complete the registration process I get an error saying

Error registering REST service. Please ensure that you have entered a proper mapping and path.

No mapping found for path /Applications/ColdFusion2016/cfusion/wwwroot/CFC/testServices .

If mapping is not specified, path should point to application root directory.

In an effort to keep this as simple as possible I'm not using mappings of any kind and all of my files are in the same folder. The instructions on the form control say to use "Application path or root folder where CFCs reside"

Does anyone know what I need to do to register my REST service in the CF Admin?

I created 3 simple files:

Application.cfc (contains only cfapplication name="test" tag, which is empty)

service.cfc

<cfcomponent rest="true">

  <cffunction name="get" access="remote" returntype="String" httpmethod="GET">

    <cfset rest = "Hello World">

    <cfreturn rest>

  </cffunction>

</cfcomponent>

serviceTest.cfm

<cfhttp url="http://127.0.0.1:8510/rest/testService/service" method="get" port="8510" result="res"> </cfhttp>

<cfdump var="#res#">

Thanks in advance,

Rich

Views

3.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 11, 2017 Dec 11, 2017

Rich, I think I have your answer. Sadly, you may be being misled by the error message. 

 

TLDR: Despite the error shown, the problem may not be in WHERE or even HOW you were trying to define the REST service, but rather a mistake that would keep the page running at all, such as one in your application.cfc (as I will propose may be the issue in your case), and which is keeping the REST service/cfc from being registered.

 

Before I elaborate, though, including how I figured that out, I want to add

...

Votes

Translate

Translate
Engaged ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

Have you tried an absolute path?  If you don't use an absolute path, I believe you need to use a mapping that was defined in the admin (which points to an absolute path).

-Nic

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

The only path that the CF Admin form control seems to accept is one from the "Browse Server" button.... When I try to enter anything else it just appends the absolute path from the hard disk anyway....

So even though the physical path on the drive is /Applications/ColdFusion2016/cfusion/wwwroot/CFC/testServices

I can try just entering /CFC/testServices and I still get the entire path spit back at me in the error message....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

Can anyone chime in with an example of what they did with the actual CF Admin settings and your file structure? I'm sure an example would straighten this right out....

Thanks in advance,

Rich

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

As an additional test I created a server mapping in the CF Admin as follows:

/restService /Applications/ColdFusion2016/cfusion/wwwroot/CFC/testServices/CFC/

And then I tried to register the REST service I entered a root path:

/Applications/ColdFusion2016/cfusion/wwwroot/CFC/testServices/CFC/

... and a service mapping:

/restService

And got the following error message:

Error registering REST service. Please ensure that you have entered a proper mapping and path.

Application /restService could not be initialized.

Reason: ''

Has anyone actually registered a REST service using the CF Admin?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

I have not, so hopefully someone that has used the service can chime in.  I see that you are on Linix. Sorry I missed that and assumed you were using a relative path. Looking at the docs I see that there are two steps:

1. Check "Allow REST discovery" in Server Settings > Settings

2. Register the CFC like you are doing

The Mapping is just the shortcut for the full URL. 

https://helpx.adobe.com/coldfusion/api-manager/getting-started-coldfusion-api-manager.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

Rich, I think I have your answer. Sadly, you may be being misled by the error message. 

 

TLDR: Despite the error shown, the problem may not be in WHERE or even HOW you were trying to define the REST service, but rather a mistake that would keep the page running at all, such as one in your application.cfc (as I will propose may be the issue in your case), and which is keeping the REST service/cfc from being registered.

 

Before I elaborate, though, including how I figured that out, I want to address a couple points of frustration you expressed.

 

1) You ask , “Has anyone actually registered a REST service using the CF Admin?”. Well yes, of course they have. 🙂

 

The CF REST feature has been used by folks since CF10 came out 5 years ago. There are also many blog posts and articles since then showing people using it. And Adobe has built an entire new API Manager that supports CF REST integration. And of course there are organizations who serve their REST services via CF. So the feature does indeed work, and people have used the Admin to register them (though it’s no longer the only way to register them).

 

2) And as for the challenging finding any answers, you don’t refer to whether you searched the web for: “Please ensure that you have entered a proper mapping and path” and “No mapping found”. I did, and curiously when I search for those phrases together in Google, I find no other references to it (well, I find your post here, and one other that did not really have both errors in it).  That suggests something about this situation which may be unusual.

 

3) Moving on to what MAY be your real problem, and how someone might find their if they get this error, had you tried calling the CFC (as a CFC itself, not as REST) via your browser? I mean (using your indicated 8510 port, and the path to where the code lives if web-accessible), http://127.0.0.1:8510/CFC/testServices/service.cfc?method=get. A lot of people don’t know it’s possible, or in their focus on calling the CFC via REST they may not consider it.

 

But if you had, you might find that this is NOT in fact a REST problem.

 

4) Indeed, based on what you said, I'd think you would have gotten an error, saying that CF “Could not process Application.cfc successfully”. (Heck, even a blank test.cfm page put into that directory and called in your browser would have reported the same error.)

 

You said that your application.cfc “contains only cfapplication name="test" tag, which is empty”. And the problem is, that’s not correct. So do you mean you have ONLY this in your application.cfc:

 

<cfapplication name="test">

 

Or do you mean:

<cfcomponent>

   <cfapplication name="test">

</cfcomponent>


Either way, it would not work. I tried it, and got your errors.

 

And whether calling the CFC or even a blank test.cfm page in that folder would produce the error: “Could not process Application.cfc successfully”. Sadly, it doesn’t say any more than that, so you may still have been stuck. 

 

So what’s the solution, in this case? Well, one way you could write your Application.cfc would be this (there are of course, many forms, script-based, or with more metadata):


<cfcomponent>

<cfset this.name="test">

</cfcomponent>

 

With that, an empty test.cfm page would now “work” (not get that error). More important, a call to the CFC via HTTP (not as REST) would now work (returning the string you had the method return).

 

And best of all, now your CFC can be registered without error. 🙂

So sadly, you were being misled by the fact that the admin was tripping over this error (which even itself was not as clear as it could be). Bummer indeed, but again at least this will stand for anyone else who may ever see this error.


5) Before we go, and back to the service mapping, I notice an inconsistency in your example code in your first message. You refer to /testServices for the root path, but then you show your CFHTTP test call with the URL as http://127.0.0.1:8510/rest/testService/service. That would have failed.

 

Then your later notes said you were trying to put into the Admin in a “service mapping” of /restService, singular. 

If you DID use that, then your CFHTTP call (or a browser URL) to test things would need to have been:

 

http://127.0.0.1:8510/rest/restService/service


6) Note that you could also leave off the “service mapping” in the Admin registration, and then it would use the name you gave for the application.cfc name, which you said was “test”, so:

 

http://127.0.0.1:8510/rest/test/service

 

Or FWIW you could have done any of the other forms of CFC registration (programmatic or application-level).

 

7) This (and lots more on REST) is covered in a chapter of the 2000+ page “Developing ColdFusion Applications” manual, specifically this (large) page:

 

https://helpx.adobe.com/coldfusion/developing-applications/changes-in-coldfusion/restful-web-service...


And the discussion of doing REST without using the Admin is in the section, “Site-level REST application support” (2/3 down the document).

 

Hope that helps. That's what we volunteers here try to do.


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 12, 2017 Dec 12, 2017

Copy link to clipboard

Copied

Charlie

Thanks so much for your help, and being... you!

My initial Google searches did in fact, come back fruitless.... Additionally I have a few other senior level CF resources and when I initially asked them (before posting to this forum) about this issue, well, collectively none of us had ever used this feature of REST in CF. Oddly, and almost at the same time we all remembered that calling the CFC just once from the browser would have greased the wheels and moved me forward.

I try to remember that not only are these forums manned mostly with volunteers but that I need to spend more time jumping in on some questions to help others and give back to the very community that has helped me as well.

As always your help is appreciated!

Rich

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

6 years later and the idea to look into the Application.cfc is still valuable. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 24, 2024 Mar 24, 2024

Copy link to clipboard

Copied

LATEST

Glad to have helped, both of you. 🙂 There are often a lot of moving parts in solving problems like this, and considering what those may be is usually the biggest challenge. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation