findOne() and findByID() Railo Issue

168 views
Skip to first unread message

Sean Daniels

unread,
Sep 7, 2012, 2:48:14 PM9/7/12
to cfmo...@googlegroups.com
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)
Messagevariable [BYID] doesn't exist
StacktraceThe 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...

Sean Daniels

unread,
Sep 7, 2012, 2:51:02 PM9/7/12
to cfmo...@googlegroups.com
Sorry, the workaround code above is not correct, in case anyone else tries it. What I actually use is:

find( {"_id":myID} ).asCursor().limit(1).toArray()[1]

Marc Esher

unread,
Sep 7, 2012, 4:41:47 PM9/7/12
to cfmo...@googlegroups.com
Sean, 

I do indeed remember this problem, and at that time I suspected it was Railo using the wrong method as well.  

Would you bring this up with the Railo folks?

It's been a long time since I've tested CFMongoDB on Railo, but I seem to remember this working at one point. I'll have to find some time to at least test it, though if it's choosing the wrong method I"m not sure how much we can do other than file a bug report with a sample demonstrating the behavior.

Marc

--
You received this message because you are subscribed to the Google Groups "CFMongoDB" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfmongodb/-/r876YHZERqAJ.
To post to this group, send email to cfmo...@googlegroups.com.
To unsubscribe from this group, send email to cfmongodb+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfmongodb?hl=en.

Sean Daniels

unread,
Sep 12, 2012, 10:49:30 AM9/12/12
to cfmo...@googlegroups.com
Interesting, I just set up a brand new Railo server using the 4.0 beta. Running the examples on this clean install worked out of the box.

So perhaps this is "fixed" in 4.0 or only was "broken" on my particular install of 3.3.

Marc Esher

unread,
Sep 12, 2012, 7:51:15 PM9/12/12
to cfmo...@googlegroups.com
Good to know. Thanks, Sean!

--
You received this message because you are subscribed to the Google Groups "CFMongoDB" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfmongodb/-/ATTpWgMbeBoJ.

Indy Nagpal

unread,
Apr 30, 2013, 11:15:34 PM4/30/13
to cfmo...@googlegroups.com
I tried cfmongodb both on Railo 3.3.4 as well as 4.0.4. And I had issues with findByID() as well as findOne(). The underlying Java object was returning null on Railo for some reason (I'm sure it is some sort of a conflict / low-level typing issue).

That led me to examine the jar files that ship with cfmongodb. The issue seems to be caused due to cfmongodb/lib/mongo-2.10.1.jar file.

If you remove that and replace with what would appear to be the latest version 2.9.3 of Mongo Java Driver available at at the MongoDB site (http://central.maven.org/maven2/org/mongodb/mongo-java-driver/2.9.3/), all seems to work ok.

Chris Blackwell

unread,
May 1, 2013, 12:02:28 PM5/1/13
to cfmo...@googlegroups.com
version 2.10.1 is newer than 2.9.3
but the latest version is 2.11.1


To unsubscribe from this group and stop receiving emails from it, send an email to cfmongodb+...@googlegroups.com.

To post to this group, send email to cfmo...@googlegroups.com.

Indiver Nagpal

unread,
May 1, 2013, 1:43:16 PM5/1/13
to cfmo...@googlegroups.com
I will try 2.11 and see what happens.

Indiver

You received this message because you are subscribed to a topic in the Google Groups "CFMongoDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cfmongodb/IzPQPplvuZg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to cfmongodb+...@googlegroups.com.

Indiver Nagpal

unread,
May 1, 2013, 2:09:06 PM5/1/13
to cfmo...@googlegroups.com
And that library also fixes the findOne and findOneByID issue.

Marc, do you want me to log an issue on GitHub to replace the library to 2.11?

Indy

Marc Esher

unread,
May 3, 2013, 9:26:10 AM5/3/13
to cfmo...@googlegroups.com
Indy,

Sure... in fact feel free to replace the existing jar and submit a pull request.

Marc

Alex Sante

unread,
Feb 5, 2014, 5:20:46 PM2/5/14
to cfmo...@googlegroups.com
I'm still seeing this issue come up.  Restarting tomcat/railo a few times until it "fixes" itself has been my workaround.  My cfmongodb lib folder consists of the following files:

cfmongodb.jar
mongo-2.11.3.jar
mongo-java-driver-2.11.3.jar
mxunit-ant.jar

and the javaloader folder.
Reply all
Reply to author
Forward
0 new messages