web stats
MongoDB Driver JAR - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-19-2015, 08:52 AM
TMarz TMarz is offline
OBX.2 Kenobi
 
Join Date: Jul 2009
Posts: 60
TMarz is on a distinguished road
Default MongoDB Driver JAR

So I have read the handful of posts on here about attempts to connect Mirth to a MongoDB instance. It looks like the only posts that declare success are ones that implement a REST interface to the DB.

But the official MongoDB JAR should be fairly straight forward to implement. However, I can't seem to get it off the ground. Here is the relevant info:

I have tried with 2 different versions of Mirth 2.2.2 and 3.0.3

I dropped the 2.13 version of the MongoDB Driver JAR into the custom-lib folder and bounced the Mirth server. Then tried to instantiate the MongoDB Client class in a channel like so:

In the Deploy Script
Code:
//Create DB Client Instance
//importPackage(Packages.com.mongodb);
var mongoClient = new Packages.com.mongodb.MongoClient("localhost",27017);
//var mongoClient = new Packages.com.mongodb.MongoClient()

globalChannelMap.put('mongoDBClient', mongoClient);
As you can see I tried a few different strategies all to no avail. If I try to use the importPackages function, then the MongoClient declaration errors for being undefined which would mean Mirth can't find the class in the Package (if it was even imported). If I try to just instantiate the one class, I get the dreaded:

Quote:
TypeError: [JavaPackage com.mongodb.MongoClient] is not a function, it is object.
After looking at some of the Mirth forum posts regarding this error, I downloaded the source from GitHub and recompiled the JAR to make sure there was no compression but still no dice.

So, my question, other than "What the hell could be the problem?" is, "Has anyone managed to use this driver in Mirth??"

All ideas, help or feedback is appreciated.

I have attached the JAR below.
Attached Files
File Type: jar mongo-java-driver-2.13.0-javadoc.jar (1.10 MB, 2 views)
Reply With Quote
  #2  
Old 03-19-2015, 11:40 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,117
narupley is on a distinguished road
Default

That is not the JAR containing the actual classes. It's a Javadoc JAR.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 03-22-2015, 12:27 PM
TMarz TMarz is offline
OBX.2 Kenobi
 
Join Date: Jul 2009
Posts: 60
TMarz is on a distinguished road
Default

Apologies. This is the correct one.
Attached Files
File Type: jar mongo-java-driver-2.13.0.jar (589.6 KB, 17 views)
Reply With Quote
  #4  
Old 03-23-2015, 07:14 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,117
narupley is on a distinguished road
Default

Make sure you've included that JAR, not the Javadoc one you initially posted. I tried it out and it works perfectly for me.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #5  
Old 03-23-2015, 08:05 AM
TMarz TMarz is offline
OBX.2 Kenobi
 
Join Date: Jul 2009
Posts: 60
TMarz is on a distinguished road
Thumbs up [Resolved]

That is so strange, Nick. I don't doubt you but I double checked that I wasn't using the javadoc jar and even had another developer try the jar independently of my instance. No dice. The jar appears to be loaded by the JVM but the classpath just doesn't seem to be found when I try to instantiate any of the classes.

But I am very appreciative that you looked for me. If anyone else come across this thread and is having similar trouble they will at least get confirmation that somebody got it to work.

For my part, I found an "unofficial" driver from a guy name Allan Bank called MongoDB Asynchronous Driver and it worked for me. Admittedly, I am not done fully testing it out, but it appears to do the job and the objects, interfaces and classes all seem pretty straight forward.

If anyone is interested, here is a link to the drivers site which has resources like FAQ, Getting Started and the full API documentation.

http://www.allanbank.com/mongodb-async-driver/

I also included a copy of the driver jar below. Maybe this thread will help someone down the line.
Attached Files
File Type: jar mongodb-async-driver-2.0.1.jar (538.7 KB, 12 views)
Reply With Quote
  #6  
Old 03-26-2015, 04:42 AM
rpanjabi rpanjabi is offline
What's HL7?
 
Join Date: Nov 2013
Posts: 3
rpanjabi is on a distinguished road
Default Not working for me

Hi,
I have tried the mongo-java-driver-2.13.0.jar and mongodb-async-driver-2.0.1 both the files. its not working for me. Attached the Error file while trying to launch Administrator. Please help me.
I am using Mirth connect 2.2.3 version.
Can you please provide me the steps and complete channel to connect Mirth to mongo db?

Thanks in advance.

Ravi Panjabi
Attached Images
File Type: jpg Mirth to Mongo Error.jpg (186.5 KB, 15 views)
Reply With Quote
  #7  
Old 03-26-2015, 07:01 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,117
narupley is on a distinguished road
Default

Do not put anything in client-lib. You should have put that in custom-lib.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #8  
Old 03-31-2015, 12:51 AM
rpanjabi rpanjabi is offline
What's HL7?
 
Join Date: Nov 2013
Posts: 3
rpanjabi is on a distinguished road
Default

Hi TMarz,

Can you please upload the channel with the information how to connect to Mongo db. It will be really helpful for me. I am trying my hand on connecting to Mongo from mirth and reading/writing data, but it is not working for me.

Thanks in advance.

Ravi Panjabi
Reply With Quote
Reply

Tags
drivers, jar, mongodb

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:03 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation