using trireme for load *.jar

Greetings,

I would like to use custom jar directly in my project (MSSQL driver in this case) to have each project fully independent from each other.

I know its possible to copy jar file into custom_jars folder and restart message processor, and its working for me. But, don't wont to have "shared" jars, and want to avoid from reset message processor each time when need add new jar file.

I wrote example to test trireme.loadJars

process.env.NODE_DEBUG = 'jdbc';

var trireme = require('trireme-support');
var loadResults = trireme.loadJars('./jar/sqljdbc4.jar');

console.log('loadResults', loadResults);

var jdbc = require('trireme-jdbc');
var db = new jdbc.Database({
    url: 'jdbc:sqlserver://*******',
    properties: {
        user: '******',
        password: '******'
    }
});

db.execute('SELECT 1', null, function(err, result, rows) {
    console.log(err, result, rows);
});

but getting me output:

[Error: No suitable driver found for jdbc:sqlserver:....

console.log('loadResults', loadResults); returns for me loadResults {} - seems nothing.

I know I can use trireme class path instead trireme.loadJars like that: (it's also working for me)

export TRIREME_CLASSPATH=./jar/sqljdbc4.jar 

but I'm not able to export env variable inside apigee environment (or I don't know about).

Solved Solved
0 5 503
1 ACCEPTED SOLUTION

Not applicable

Hi and thanks for trying this!

The problem is that JDBC -- the Java API -- does not give us a straightforward way to load a JDBC driver from a custom classpath. So, Trireme has no way to use the custom classloader created by "loadJars" to load the JDBC driver.

Today, the only option is to put the JDBC driver on the system classpath.

View solution in original post

5 REPLIES 5

Not applicable

Hi and thanks for trying this!

The problem is that JDBC -- the Java API -- does not give us a straightforward way to load a JDBC driver from a custom classpath. So, Trireme has no way to use the custom classloader created by "loadJars" to load the JDBC driver.

Today, the only option is to put the JDBC driver on the system classpath.

Not applicable

I would like to know steps for using/adding new jar.

Step 1: Set TRIREME_CLASSPATH setting in the apigee-env.sh file - Believe this will be taken care of including classpath during restarting apigee

Step 2: Keep the jar file part of node code (Not sure, should we place it in any folder directly)

Step 3: Restart the MP

Please update/correct any other steps required.

Not applicable

To answer @Paranitharan Govindasamy's question -- if you want to access Java code from inside Trireme, including for the trireme-jdbc module, then adding it to the system classpath for the message processor should always works. Once it's there there's no need to put the file anywhere else.

I have added the JDBC jar in TRIREME_CLASSPATH and restarted the MP. I am getting the error as "no main manifest attribute, in <jar>'. The jar should be executable, if needed to be added in the classpath? I could load that jar in other sql clients and loaded without any error. Does anybody encounter this issue?

Hi there

Is it possible to upload JDBC driver by loadJars in the lasters Edge version 4.17.9 ?