Author |
Message
|
IIB_Intel |
Posted: Tue Mar 07, 2017 1:56 pm Post subject: calling java method in shared lib from JCN in application |
|
|
Acolyte
Joined: 07 May 2015 Posts: 64
|
I have a JCN (App_jcn.java) which is present in the java project of an application, can I call a java method present in a class of a java project in shared library let's say named SH_LIB_A?
I know I can definitely do this if the JCN (App_jcn.java) itself part of the shared library SH_LIB_A or another shared library SH_LIB_B (where SH_LIB_B refers SH_LIB_A). |
|
Back to top |
|
 |
timber |
Posted: Tue Mar 07, 2017 2:29 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
|
Back to top |
|
 |
IIB_Intel |
Posted: Tue Mar 07, 2017 3:29 pm Post subject: |
|
|
Acolyte
Joined: 07 May 2015 Posts: 64
|
My original question was based on this link itself. When I try to give a shared library classloader on JCN node whose's java class present in the application itself, it doesn't compile.
I want to make sure if that is the expected behavior or am I doing anything wrong?
Following statement from the link is confusing, seems like a typo.
Quote: |
A JavaCompute node in a message flow or subflow can access the Java classes in a shared library and any referenced shared libraries. The following diagram shows a JavaCompute node in a message flow in an application, but the JavaCompute node could be in a subflow in a shared library. |
|
|
Back to top |
|
 |
mqjeff |
Posted: Wed Mar 08, 2017 6:50 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
A "shared lbirary" is a deployment object.
Each shared library runs in it's own classloader. That's the picture
Each shared library classloader that references another shared library keeps it's own copy of any jars in that referenced shared library in it's own classloader. .
A JCN can reference a single shared library, by it's prefix isurrounded by {}.
Any number of JCNs can access the same shared library. Any java external procedure in ESQL can reference the same shared library.
You can not use classes outside of the shared library in the shared library, nor vice-versa. So if your shared library references log4j (you're doing it wrong in that case), you have to include the log4j jar file in that shared library. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
IIB_Intel |
Posted: Wed Mar 08, 2017 7:30 am Post subject: |
|
|
Acolyte
Joined: 07 May 2015 Posts: 64
|
Quote: |
A JCN can reference a single shared library, by it's prefix isurrounded by {}. |
This also means the JCN java class has to be in the shared library? As if that is in the application's java project then that would use broker wide class loader and a class in classloader A cannot use class in classloaderB.
If my understanding is true then it answers my original question.
Quote: |
You can not use classes outside of the shared library in the shared library |
Are you sure on this? as I did a quick test where my log4j jar was present in the shared-classes folder and I tried access it in a java class in my shared lib and was able to log. Yes of-course, it bring the class from shared-classes to its shared library loader. |
|
Back to top |
|
 |
IIB_Intel |
Posted: Wed Mar 08, 2017 11:23 am Post subject: |
|
|
Acolyte
Joined: 07 May 2015 Posts: 64
|
I got the answer to my question.
From IBM - Java classes in applications, static libraries, or independent projects cannot access Java classes in shared libraries. |
|
Back to top |
|
 |
|