I can't seem to get findByID() or findOne() to work on Railo (3.3.5). I saw an earlier thread related to this but the "solution" there does not apply to me, I don't have the Mongo extension installed and the only mongo.jar in play is the one from cfmongodb (I've actually upgraded it to 2.9.0 at this point, but it didn't work with 2.7.5 either). The issue even effects the example page out of the box - I get the error:
Railo 3.3.5.002 Error (expression) |
Message | variable [BYID] doesn't exist |
Stacktrace | The Error Occurred in
/var/www/sites/cfmongodb/examples/gettingstarted.cfm: line 125
123: byID = people.findById( url.personId ); 124: writeOutput("<h2>Find by ID</h2>"); 125: writeDump(var=byID, label="Find by ID: #url.personID#", expand="false"); 126: 127: //using count(), SearchResult.totalCount(), and SearchResult.size()
called from/var/www/sites/braunsmedia.scribble/index.cfm: line 1 |
The issue seems to boil down to the Java driver's findOne() method, which always returns NULL for me, even when I know a document exists with the criteria. I believe this may have to do with Railo using the incorrect method signature, using findOne(java.lang.Object) instead of findOne(com.mongoDB.DBObject)?
A workaround is to use find({"_id":myID}).limit(1)[1] but it's kludgy and blows up if no doc with the ID is found. Marc mentioned using command() to call findOne instead, I'm thinking of modifying DBCollection.cfc to do this and see if it works.
But I guess my general question here is, is anyone out there successfully using findOne() or findByID() on a Railo server? Just making sure I'm not crazy...