11 Replies Latest reply on Feb 28, 2010 6:13 PM by Drew Nathanson

    CF 9 ORM -- CFCLocation not working

    Drew Nathanson Level 1

      Hi There,

       

      I have just started looking at ORM in CF9 and am having a problem with the CFC location. I have tried moving the CFC I'm testing with to another directory, changed the ormsettings.cfclocation to a bunch of different things, added in a mapping in the administrator and still come up short with the CF9 error: "Mapping for component .... ".

       

      Adobe certainly doesn't give you much information about what the format is support to be, and how it is to work.

       

      Here is what I have:

       

      Windows version with Apache 2.0.59

       

      Application.cfc:

       

         this.ormenabled                     = true;
         this.datasource                      = "testit";
         this.ormsettings                     = { };
         this.ormsettings.cfclocation     = "/App/CFC";
         this.ormsettings.dbdialect        = "MicrosoftSQLServer";

       

      Directory structure:

       

        /test/app <-- Source .CFM module

        /test/app/cfc <-- Home of all my CFC's

       

      Test.cfm

       

      <cfset dbData = EntityLoad("tableA1", {id=3})>

       

      Results:

        Error: Mapping for Component tableA1 not found.

       

      Okay, I have spent hours trying and searching the next for answers as to how to make this work.

       

      Any help would be greatly appeaciated.

       

      Drew Nathanson

      Technical Synergy, Inc.

      drew@technicalsynergy.com

        • 1. Re: CF 9 ORM -- CFCLocation not working
          Adam Cameron. Level 5

          It shouldn't matter, but I notice the case of your code and the actual dir names in the file system doesn't match.

           

          Bear in mind that whilst CF and the file system might not be: Java is case sensitive.

           

          --

          Adam

          • 2. Re: CF 9 ORM -- CFCLocation not working
            Adam Cameron. Level 5

            Oh, and Apache certainly is.

             

            --

            Adam

            • 3. Re: CF 9 ORM -- CFCLocation not working
              Drew Nathanson Level 1

              Thanks. However, the code that I displayed is only a sample. The directory structure is with mixed

              cases and everything is correctly match.

               

              However, what is the correctly ormsettings.cfclocation format? I have read a posting at google that its suppose to a fully qualitied path and others that its relative. In my case, neither of them work.

               

              Thanks for all your suggestions.

              • 4. Re: CF 9 ORM -- CFCLocation not working
                Adam Cameron. Level 5

                Ah, OK! It's always best to post your exact code, rather than an approximation of it ;-)

                 

                I've always used a full path.  And it's always worked.

                 

                In your example, the dir you are representing as /test/... is that the CF webroot?

                 

                Can you browse to the CF via the path /app/cfc/tableA1.cfc

                 

                The CFCs don't need to be browseable for Hibernate to access them, but browsing to a CFC and seeing if it works is always a quick way to find compilation errors.

                 

                If the dir isn't browseable, can you instantiate the CFC via createObject("component", 'app.cfc.tableA1");

                 

                ?

                 

                --

                Adam

                • 5. Re: CF 9 ORM -- CFCLocation not working
                  Drew Nathanson Level 1

                  Adam,

                   

                  I apologize for the error in the example, here it is again (as it appears in my Application.cfc):

                   

                  // Set ORM fields
                  this.ormenabled                     = true;
                  this.datasource                     = "testit";
                  this.ormsettings                    = { };
                  this.ormsettings.cfclocation     = "/Test/App/CFC";
                  this.ormsettings.dbdialect        = "MicrosoftSQLServer";

                   

                  Directory structure (windows):

                   

                     D:\Apache2\htdocs (web root)

                   

                         \Test\App  <---- CFM Module

                         \Test\App\CFC  <-- CFC module

                   

                  Now, if I understand you correctly, the application location description is correct.

                   

                  However, I still get an error. Since the entire server is my local machine, I have no restrictions on directory visiblity. Is there something that I should try that I'm not doing to make sure. Apache access has never been an issue for me normally and this is an application that I have running and copied to try to use ORM on it.

                   

                  I tried your suggestion of instantiating the object however that also doesn't work.

                   

                  Is there any administration configuration issues that need to be addressed not done in the normal configuration?

                   

                  Thanks for all your help,

                   

                  -Drew

                  • 6. Re: CF 9 ORM -- CFCLocation not working
                    Adam Cameron. Level 5

                    All your settings look fine, and that's all you should need to do to get things going.

                     

                    However given this:

                     

                    I tried your suggestion of instantiating the object however that also doesn't work.

                     

                    I'm wondering if there's an error in you CFC.  When you say "doesn't work", what do you mean?  Doesn't work in what way?  An error?  What's the error message?

                     

                    Did you just try browsing to the CFC?  Can you?

                     

                    --

                    Adam

                    • 7. Re: CF 9 ORM -- CFCLocation not working
                      Adam Cameron. Level 5

                      And you've tried using "D:\Apache2\htdocs\Test\App\CFC\" as the cfclocation?

                       

                      --

                      Adam

                      • 8. Re: CF 9 ORM -- CFCLocation not working
                        Drew Nathanson Level 1

                        Adam,

                         

                        Here is the CFC:

                         

                        <cfcomponent table="tableA1" persistent="true" entityname="tableA1">

                         

                            <cfproperty name="User_ID"               Column="USER_ID"                       DataType="Integer"     Length="10" />
                            <cfproperty name="User_Name"          Column="USER_NAME"                DataType="Varchar"     Length="200" />
                            <cfproperty name="Login_ID"              Column="LOGIN_ID"                      DataType="Varchar"     Length="30" />
                            <cfproperty name="Password"              Column="PASSWORD"                DataType="Varchar"     Length="30" />
                            <cfproperty name="Outside_Access"     Column="OUTSIDE_ACCESS"      DataType="Integer"     Length="10" />
                            <cfproperty name="Access_Level_ID"     Column="ACCESS_LEVEL_ID"     DataType="Integer"     Length="10" />
                            <cfproperty name="Creation_Date"       Column="CREATION_DATE"           Datatype="Date"     Length="7" />
                            <cfproperty name="Last_Update_Date" Column="LAST_UPDATE_DATE"     DataType="Date"     Length="7" />

                         

                        </cfcomponent>

                         

                        The error that I receive is: Mapping to Component tableA1 is not found.

                         

                        The following is the code that I am using to get to the object:

                         

                        <!--- Instantiate the cfc object (this was added in at your suggestion) --->

                        <cfobject Component="Test.App.CFC.tableA1" Name="tableA1" />

                         

                        <!--- Retrieve the table object --->

                        <cfset dbData = EntityLoad("tableA1", {user_id=3})>

                         

                        I also tried this:

                         

                        <cfset dbData = EntityLoad("tableA1")>

                         

                        with the same results ... error in not finding the component.

                         

                        One more thing, I have tried http://localhost/Test/App/CFC/tableA1.cfc at the browser but I get no response. I have the security open to accept this however I don't get a response. This also doesn't work with any of my already working CFC's so I'm not sure if there is something wrong with CF or there is another problem someplace else.

                         

                        Yes, I have tried d:\Apache2\htdocs\Test\App\CFC in ormsettings.cfclocation tag with the same results.

                         

                        -Drew

                        • 9. Re: CF 9 ORM -- CFCLocation not working
                          Adam Cameron. Level 5

                          Ah, OK, you're gonna have to switch ORM off or run this test code from a different application whilst doing the troubleshooting... the entire application is failing to start because of the ORM error, so your troubleshooting (the <cfobject> call and browsing directly to the CFC) will break because they require the application to start-up properly.

                           

                          So set ormenabled to false whilst trying those two.

                           

                          When I do this, I get an error saying:

                           

                          Id field not defined for cfc tableA1 and it can not be figured from DB as table tableA1 does not exist.

                           

                          So are you mapping this CFC to an existing table?  If so, what's the table-create SQL?

                           

                          --

                          Adam

                          • 10. Re: CF 9 ORM -- CFCLocation not working
                            Drew Nathanson Level 1

                            Adam,

                             

                            Actually the problem was in a control file that I have for the site. It is used to control processng and block things like hijacked pages, etc. It would seem that it was blocking my efforts. I have fixed it and now everything is responsing correctly.

                             

                            Thank you for all your help. This is a start for me now to learn how to use ORM.

                             

                            Again, thanks.

                             

                            -Drew