January 29th, 2013, 12:12 PM
REST CFC on Win7 and Apache
Last night I spent 6 hours (no kidding) trying to get a hello world REST CFC to work and could not. Very disappointing. I have been using CF for 12 years and have been using Jersey for a year in java. There is so much conflicting information out there on setting this up that it is just hard to know which tutorial to believe.
My environment is my Windows 7 PC running CF10 downloaded about 6 months ago coupled with Apache and for this test site I am listening on port 8080 and using a virtual host.
I have tried every possible permutation of:
Using and not using forward or backward slashes in restPath parameters.
Moving my entire site underneath or outside of htdocs so it is within webroot.
Putting "/" in my function resPath
Having only one "Get" method in my CFC
Refreshing CF app server a gazillion times
Playing with mappings in CFadmin to have my CFC located
Using CFAdmin or the function call to register the service
Using the Application.cfc (this.name) in url calls
If it is out there on the web I tried it last night!
Nothing - SO VERY FRUSTRATING. Usually CF is plug and go but perhaps many kinds still in REST/CFC
The url I am trying to use is:
Ultimately I want a REST service component I can make ajax calls to for reference data.
Let's start with the basics, from the environment I have just described are there any known issues that would prevent this from working? Are there any patches I need for my CF10 from 6 months ago for running on Win7?
thanks - I am trying to put together a prototype to present at my MAJOR telecomm company. They are not currently a CF shop but I believe so strongly in CF I want to get it going in there. This is disheartening though!
January 29th, 2013, 02:24 PM
I haven't used the REST CFCs in 10 yet. Would something like this tutorial help?
January 29th, 2013, 03:03 PM
Thank you for your reply. This is one of MANY tutorial/presentations I looked at last night trying to get his working. I also looked at Ray Camden's site a presentation by the Salt Lake users group, some Adobe "getting started" articles and many more.
Again I want to ask if there have been patches put out that address any REST related issues, if running via virtual host on Apache on port 8080 should be OK (other normal page and CFC operations are fine), if the CFC MUST be within the web root (htdocs for me).
Also many folks seem to be putting a call to the register function on each page request. Is that needed? I wouldn't think so but I keep seeing that popup too. Folks are putting calls to that function in Application.cfc on the request start.
Judging by the number of posts I've found in these forums I wouldn't guess this has been highly adopted yet but I hope I'm wrong.
Again - thanks to anybody who has any type of info for me on this. It is appreciated. If I can get this going it would be a major step in me selling CF into my LARGE workplace.
January 29th, 2013, 04:21 PM
On the patches question, I can't say for certain if this particular thing is in one of them, but there have been several updates for CF10 and you always should be running the most recent updates/hotfixes. If you aren't, the first thing I'd do is update.
January 30th, 2013, 09:39 AM
I found out what the issue was. I had two virtual hosts setup in my Apache httpd.conf file and one was interfering with the other I believe. I had one listening on port 80 for a site I maintain for a client of mine. The second one is listening on port 8080 and that is the test site where I've been trying to get REST going.
Among other things I commented out the whole virtual directory for the site on port 80 and I now have some basic REST ops working off of port 8080.
I just wanted to post quickly that I have a working configuration.
Tonight when I have more time I will add one more post onto this thread to post what I feel is relevant information about my working configuration so others that read will see something that is working for me.
February 23rd, 2013, 10:51 AM
For anybody monitoring this post, apologies for not posting code / config info.
As a final resolution I'm posting that the cause of my issues was rooted in how apache was involved in my environment. I have seen that 1 environment waffle back and forth between working and not working and have not isolated the exact issue but have a high confidence that it has to do with my web server config.
The reason for this is that I stood up a completely separate environment and used the built in web server listening on the default port to test on and my REST CFC just worked immediately.
I don't think it has to do with the port. Most likely something to do with virtual directories or pathing in some way.