If you have library modules you're importing, the query may work fine in cq, but if you try to use the same query via the XCC layer you may get "File Open Error" messages.
One cause of this for me was the pathing in the import statement. cq seems to handle a relative path while XCC cannot, at least in MarkLogic 4.1.
I needed to change from...
import module namespace my = "http://blah.com" at "search-parser-xml.xqy",
import module namespace my = "http://blah.com" at "/search-parser-xml.xqy",