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
Copy link to clipboard
Copied
What version of CF are you using? How is your sandbox security setup?
Copy link to clipboard
Copied
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>