java calls Kettle's API and reports an error: Error initialization step [MongoDB output]java.lang.NoSuchMethodError: com.mongodb.WriteConcern.<i

Background description: Due to business needs, it is necessary to introduce kettle's Java API and use the jar package for the series of jar packages provided by pentaho. It is necessary to manage the resource library, resource library directory, scripts in the directory, etc. through code, and execute scripts and conversions. , Execution record saving, script execution task management, timing management and other functions. Based on open source project: https://gitee.com/uxue/dataCollection.git

Problem encountered: After quoting mongo driver support, an error is reported when executing the script.

Bad initialization step [MongoDB output]

java.lang.NoSuchMethodError: com.mongodb.WriteConcern.<init>(IIZZ)V

org.pentaho.mongo.MongoPropToOption.writeConcernValue(MongoPropToOption.java:170)

Problem analysis: At first glance, it should be a problem with the mongo driver. After commenting on the mongo reference, the script can start normally. After checking one by one, it was found that the pentaho-mongo-utils-9.5.0.0-240.jar package quoted mongo-java-driver- The classes in 3.12.10.jar conflict with the classes in mongodb-driver-sync-4.6.1.jar in the project. mongo-java-driver has not been updated and maintained since 2018, but the mongo connection toolkit provided by pentaho has not updated the relevant driver. I tried various methods but failed to solve the problem. Finally, I decided to separate the kettle part into a microservice form. Not introduced in code form. This solution is not very clever, but I can't think of a better solution in a short time. If there is a better solution, I sincerely hope to let you know, thank you!

Welcome to follow the public account "Mashang Hunter", [Come on, let's praise each other!

Guess you like

Origin blog.csdn.net/rice2020/article/details/131420743