Integrate MongoDB with Liferay7.2

thumbnail
Ramalingaiah. D, modified 6 Years ago. Expert Posts: 489 Join Date: 8/16/14 Recent Posts
Dear Team,

if we are using MYSQL then we need to edit portal-ext.properties .
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=root

if we are using MongoDB then what we need to do changes.
Can you please let me know . Actually i am trying to Integrate MongoDB with Liferay.

RegardsRam
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Mongo has nothing to do with Liferay and/or JDBC (and especially service builder). Nothing at all changes from your Liferay implementation details.

For Mongo, you still need the Mongo jar(s) and create a client connection to Mongo and then you just consume it as you would in any other java code, nothing special.

If you're exposing across OSGi, you want to ensure you only expose your POJOs and not any of your Mongo class dependencies. Otherwise you'll bleed the dependencies across your module landscape and complicate your dependency management.
thumbnail
Ramalingaiah. D, modified 6 Years ago. Expert Posts: 489 Join Date: 8/16/14 Recent Posts
Hi David
thank you....Regards

Ram
thumbnail
Ramalingaiah. D, modified 6 Years ago. Expert Posts: 489 Join Date: 8/16/14 Recent Posts
Hi ,
jdbc.default.driverClassName=mongodb.jdbc.MongoDriver
jdbc.default.password=admin
jdbc.default.url=jdbc.mongo://<localhost>:<27017>/<expertdb>
jdbc.default.username=welcome123
Error creating bean with name 'liferayDataSourceImpl' defined in class path resource [META-INF/infrastructure-spring.xml]: Invocation of init method failed; nested exception is java.lang.ClassNotFoundException: mongodb.jdbc.MongoDriver.
i am getting error  mongodb jdbc mongoDrive 
RegardsRam
thumbnail
Olaf Kock, modified 6 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Ramalingaiah. D:

Hi ,
jdbc.default.driverClassName=mongodb.jdbc.MongoDriver
jdbc.default.password=admin
jdbc.default.url=jdbc.mongo://<localhost>:<27017>/<expertdb>
jdbc.default.username=welcome123
Error creating bean with name 'liferayDataSourceImpl' defined in class path resource [META-INF/infrastructure-spring.xml]: Invocation of init method failed; nested exception is java.lang.ClassNotFoundException: mongodb.jdbc.MongoDriver.
There is a certain number of database engines that Liferay is compatible with. The listed open source databases apply to CE, while DXP supports all of the listed ones. Mongo DB is not among them.
When David said "For Mongo, you still need the Mongo jar(s) and create a client connection to Mongo and then you just consume it as you would in any other java code, nothing special." he was referring to your custom code being able to access a MongoDB backend as you could build it in any other environment than Liferay.
For the Liferay database itself (which you configure through the properties that you list) the other sentence applies: "Mongo has nothing to do with Liferay and/or JDBC (and especially service builder)."
thumbnail
Ramalingaiah. D, modified 6 Years ago. Expert Posts: 489 Join Date: 8/16/14 Recent Posts
Dear Olaf Kock,​​​​​
osgi not connecting   mongodb jar versions  ( mongo-java-driver-3.8.2 and mongo-java-driver-3.9.1),
which version mongodb support in liferay 7.2  ,
i am using liferay 7.2,

Regards
Ram
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Ram, you really need to read up on Mongo I think before proceeding further.

Mongo connections are not created using JDBC properties and/or a JDBC URL. A mongo client is created and it is established via a network (host/port) connection.

There is no JDBC, there is no driver, etc. Whatever you are trying to do, it really looks like you are trying to treat Mongo as though it is any old RDBMS. It absolutely is not; you connect to it in a different way, you do CRUD operations on it in a different way, etc.