• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Cannot Invoke CFC

Explorer ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

Hi-

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

getfares.cfm

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

<cfscript>

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

qFares = obj.getFares(argumentcollections = form);

//mydata = obj.queryToJSON(qFares) ;

//myjson = obj.structToJSON(mydata);

if(!findnocase("[",qFares))

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

else

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

</cfscript>

<cfprocessingdirective suppresswhitespace="yes">

       

<cfoutput>

    #replace(mydata,"/","","All")#

    </cfoutput>

</cfprocessingdirective>

Extract of my cfc

main.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#"> )

        </cfquery>      

        <cfset myResult =  QueryToStruct(qFares) />

<cfreturn SerializeJSON(myResult)>

    </cffunction>

</cfcomponent>

Can any body help

Regards

Tayyab

Views

386

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
Advocate ,
Apr 04, 2017 Apr 04, 2017

Copy link to clipboard

Copied

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

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 ,
Apr 08, 2017 Apr 08, 2017

Copy link to clipboard

Copied

LATEST

main.cfc

<cfcomponent extends=toJSON>

...

</cfcomponent>

 

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

<cfcomponent>

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