2 Replies Latest reply on Apr 8, 2017 4:14 AM by BKBK

    Cannot Invoke CFC

    Tayyab Hussain Level 1



      I am trying to crate an api that returns JSON from a set of queries in  function main.cfc when I try to run this main.cfc I get this error


      Security: The requested template has been denied access to D:/home/windsorparking.com/wwwroot/szh/szh/myapis/toJSON.cfc.

      The following is the internal exception message: access denied ("java.io.FilePermission" "D:/home/windsorparking.com/wwwroot/szh/szh/myapis/toJSON.cfc" "read")
      ColdFusion cannot determine the line of the template that caused this error. This is often caused by an error in the exception handling subsystem.


      My Calling Program



      <cfparam name="form.userid" default="4">



      obj = CreateObject("component","main");

      qFares = obj.getFares(argumentcollections = form);

      //mydata = obj.queryToJSON(qFares) ;

      //myjson = obj.structToJSON(mydata);


      mydata = "[" & replace(qFares,"/","","All") & "]";


      mydata = replace(qFares,"/","","All");




      <cfprocessingdirective suppresswhitespace="yes">







      Extract of my cfc


      <cfcomponent extends=toJSON>

          <cffunction name="getFares" access="remote" returntype="string" returnFormat="json">

          <cfset myResult = {} />

          <!--- this will return the vehicle types and their rates with locaiton name --->

              <cfquery name="qFares" datasource="szhDB">

                  select f.vehicle_type_id As vhID, f.charges AS vhFee, f.LocationID AS vhlocationid, v.name As vhname , l.name AS vhlocation

                  FROM fare f

                  INNER JOIN vehicle_type v ON f.vehicle_type_id = v.vehicle_type_id

                  INNER JOIN location l ON l.locationid = f.locationid

                  WHERE f.locationid = (select locationid from deviceusers where userid = <cfqueryparam cfsqltype="cf_sql_integer" value="#form.userid#"> )


              <cfset myResult =  QueryToStruct(qFares) />

      <cfreturn SerializeJSON(myResult)>




      Can any body help







        • 1. Re: Cannot Invoke CFC
          haxtbh Level 4

          What version of CF are you using? How is your sandbox security setup? 

          • 2. Re: Cannot Invoke CFC
            BKBK Adobe Community Professional & MVP



            <cfcomponent extends=toJSON>




            To start with, let's rule out the typo, and see if it helps. Change the line to:


            <cfcomponent extends="dotted.path.from.root.to.toJSON">


            If that doesn't help then, apparently, the component, main.cfc, has no access to toJSON.cfc. In any case, the code in main.cfc suggests that the component doesn't need to be a child of toJSON.cfc. If so, you could save yourself all the trouble and just use