Skip to content
marcesher edited this page Jun 8, 2011 · 9 revisions

Requirement: MongoDB should be installed and running.

Install CFMongoDB

  • Expand the cfmongodb package into your web root or create a mapping to /cfmongodb

Make sure the Java MongoDB driver is in the ColdFusion server’s classpath

Method 1 – adding the Java MongoDB driver and the CFMongoDB jar to the CF server classpath.

  • Drop the lib/mongodb[version].jar and lib/cfmongodb.jar into a directory that’s in your ColdFusion server’s classpath
  • Start or restart your ColdFusion server instance

Method 2 – Use JavaLoader (included in distribution)

  • JavaLoader ships with CFMongoDB, and a “JavaLoaderFactory” object is provided which knows where to look for the mongodb and cfmongodb jar files
  • To use:

javaloaderFactory = createObject('component','cfmongodb.core.JavaloaderFactory').init();
mongoConfig = createObject('component','cfmongodb.core.MongoConfig').init(dbName="MyCollection", mongoFactory=javaloaderFactory);
mongo = createObject('component','cfmongodb.core.Mongo').init(mongoConfig);