0
votes

Using pentaho 5.3, Modified Java Script Value step to inject those data.

I want to dynamically set path and names in the MongoDB Output step. Here is my code

var meta = new org.pentaho.di.trans.TransMeta( source_path );
var mongoStep = meta.findStep("MongoDB Output");
mongoStep.setDescription('This is MongoDB Output by Ray');
Alert(mongoStep.getName());  // code is ok until here.
var mongoStepMeta = mongoStep.getStepMetaInterface()  // error occurs here

When I want to get the getStepMetaInterface() to use step functions, the error occurs.

java.lang.LinkageError: loader constraint violation: loader (instance of org/pentaho/di/core/plugins/KettleURLClassLoader) previously initiated loading for a different type with name "org/pentaho/metastore/api/IMetaStore"

This error seems to be generated by the violation of .jar.

But when I use those original steps, like "Microsoft Access Input", I can successfully get getStepMetaInterface(). In this way, I can use all the functions defined in AccessInputMeta.java.

From my point of view, this problem may have a relation to the MongoDB Output step, because this is a plugin for kettle, but I am not sure.

Any response is appreciated!!

2

2 Answers

0
votes

Yep, it's because of the plugin system. The Modified Java Script step and the Access Input step (among many others) are all in the Kettle engine and share a classloader. External plugins (like MongoDB Input/Output) have their own isolated classloaders. You have to do some voodoo with thread context classloaders and reflection in order to get at the Meta classes for those steps.

Here's an example of the hoops you have to jump through to get at external plugins (the Big Data plugin in this example) from the Modified Java Script step: https://github.com/brosander/pentaho-hadoop-shims/blob/verification-2/test/verification/jobs/dependencies/ForceHiveToConnectRemotely.ktr

0
votes

First, thanks to Mass who solves the problem.
Here is his advice: This problem is caused by jar file conflict.

In pentaho installation there are two jar files:

-lib/metastore-5.3.0.0-213.jar
-plugins/pentaho-mongodb-plugin/lib/metastore-5.3.0.0-213.jar

Just remove the last jar file, this error will disappear.