7 Replies Latest reply on Mar 20, 2013 11:12 PM by mchandna

    Cannot register RESTful service

    CFFan123

      I'm running CF 10 Developer (64-bit) (using IIS) on top of Windows 2008R2 (64-bit). This server is running in a Virtualbox VM on my Windows 7 Pro (64-bit) workstation.

       

      Everytime I attempt to add a RESTful service (even the most minimalistic), I get an error.

       

      For instance, this very simple CFC:

       

      /RestExample/HelloWorld.cfc

       

      <cfcomponent rest="true" restPath="/hello">

              <cffunction name="sayHello" access="remote" returnType="String" httpMethod="GET">

                       <cfset res="Hello World">

                       <cfreturn res>

              </cffunction>

      </cfcomponent>

       

      I then proceed to register the service in CF admin:

       

      Root Path: C:/websites/test/RestExample/

      Service Mapping: Example

       

      This will produce this error:

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

      Application Example could not be initialized.

      Reason: The application does not contain any rest enabled CFCs.

      The application does not contain any rest enabled CFCs.

       

      Note, if I run the following code, it will add the service.

       

      <cfscript>

      restInitApplication(getDirectoryFromPath(getCurrentTemplatePath()).concat("main\"), "Example");

      <cfscript>

       

      However, when I attempt to reach the service using its URL, I get the following error:

       

      "Error","ajp-bio-8012-exec-4","03/01/13","16:51:58","RestSample","object is not an instance of declaring class

       

      Funny enough, this same code worked when I installed CF10 64-bit on my other Windows 7 64-bit workstation without any issue. I wasn't going through IIS in this case (not that I think it makes a difference).

        • 1. Re: Cannot register RESTful service
          mchandna Level 1

          Two things here.

           

          First of all if you are not able to register REST service from Administrator and it's giving errors like "No CFC found" OR "some problem with CFC",

          then my suggestion is you try to access the cfc directly in browser as you would access any cfm.

          This will tell you if there are any errors with your cfc or not.

           

          Secondly, whenever you see this error  "obje ct is not an instance of declaring class", please refresh your service, either from Admin or from function and see if there is any error or not. If there is any error please rectify it and try again to refresh. Once refreshed succesfully, you will be able to call your REST service.

           

          Thanks,

          Milan.

          CF Engineering Team.

          • 2. Re: Cannot register RESTful service
            CFFan123 Level 1

            I was able to navigate to the cfc without any errors.

             

            I also tried to refresh/recreate my service and kept getting that error. My install must be foobar, this is too simple not to work (even though, I did reinstall once already).

            • 3. Re: Cannot register RESTful service
              mchandna Level 1

              Do you have access to ColdFusion webroot, if so then can you try to setup REST in ColdFusion webroot instead of IIS webroot.

              Make a folder in ColdFusion webroot, put your REST CFC there, try to access it in browser and then register a REST service(use different name) in Admin.

               

              This will help to nail down the issue, we will get to know if it's related to webserver.

              • 4. Re: Cannot register RESTful service
                mootinat0r

                Out of curiosity do you have "Case Sensitivity for File and Folder Names" turned on for your Windows 2008 R2 VM?

                 

                I just had a very similar problem migrating a REST service from my Windows dev box to a Linux staging server.  What resolved the issue for me was changing the file name to all lower case. i.e.: > mv HelloWorld.cfc helloworld.cfc

                • 5. Re: Cannot register RESTful service
                  CFFan123 Level 1

                  mootinat0r wrote:

                   

                  Out of curiosity do you have "Case Sensitivity for File and Folder Names" turned on for your Windows 2008 R2 VM?

                   

                  I just had a very similar problem migrating a REST service from my Windows dev box to a Linux staging server.  What resolved the issue for me was changing the file name to all lower case. i.e.: > mv HelloWorld.cfc helloworld.cfc

                  I changed to all lower case and I still get the same error. What about permissions? I'm running out of ideas.

                  • 6. Re: Cannot register RESTful service
                    CFFan123 Level 1

                    mchandna wrote:

                     

                    Do you have access to ColdFusion webroot, if so then can you try to setup REST in ColdFusion webroot instead of IIS webroot.

                    Make a folder in ColdFusion webroot, put your REST CFC there, try to access it in browser and then register a REST service(use different name) in Admin.

                     

                    This will help to nail down the issue, we will get to know if it's related to webserver.

                    OMG, this works!

                     

                    What is the difference between putting the files under an IIS website root folder vs Coldfusion wwwroot? An AppPool issue/rights?

                    • 7. Re: Cannot register RESTful service
                      mchandna Level 1

                      Creating REST Service in your ColdFusion root or connector(IIS) webroot shouldn't matter actually untill and unless your connector is properly configured.

                       

                      Can you reconfigure you connector again with admin rights and then try to create REST Service in connector webroot.

                      Also try to give all access to the REST folder.