Question

External Jar File Not Getting Connected

Hello All,

I am facing one issue i.e : we received a jar file from our java team, which when executed will give a key (String), This key will be used for further processing of Pega Flow . So the steps done by me are as follows :

1. Imported the .jar file in the Pega through Import Export wizard.

2. Restarted the Server

3. Trying to connect with the Jar file through Connect-Java method in activity.

Problem: While tracing the activity I find that the error is poping up that Class Not found .

Anyone faced the same issue ??

Attaching some of the screenshots too.

***Moderator Edit: Vidyaranjan | Tagged SR Exists***

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Group Tags

Correct Answer
April 18, 2017 - 5:38am

Ok , So Finally I am able to connect to the Jar file from Pega. And It did n't work through the Connect-java at all . I wrote a Java Script in a activity which is connecting to the Jar file seamlessly . 

Yes one more thing which is very very important, If you do have any certificates in your uploaded jar file then please be informed that the JREin which the Jar file was created should match with the JRE of your Pega application Server. 

In my case I was having a mismatch . My Jar file and the jks file and certificates were created using Sun(Oracle) jre. But in our application server we use the JRE of the IBM. So Boom there was a mismatch, The sol was to recreate the jks in IBM jre , which actually changes some Certificate format in IBM readable rather than Oracle Readable. and it worked. 

 

Actually I faced issue from starting of this to the every granular level of the implementation, but Finally it was done :) 

Comments

Keep up to date on this post and subscribe to comments

April 6, 2017 - 2:55pm

Possible to attach screenshot of your activity including where it references to the classes in the jar?  Please attach PegaRULES log file as well when you run the activity.

April 7, 2017 - 5:17am

Hi I have inserted the screenshots above in the previous post . Also the Tracer screenshot has been attached. if you need my activity screenshot it is simple page new and connect -Java method. 2 steps. 

The connect-java service which I have written is attached here. (Updated the previous file)

April 8, 2017 - 7:55am
Response to RanabirB

You should verify that the pega engine can 'see' your java class using SMA>>Advanced>>ETier Runtime environment lookup java class button. Make sure you enter the fully qualified class name. 

April 10, 2017 - 5:41am
Response to KevinZheng_GCS

HI Kevin, 

I went to SMA and did what you said. 

I do see the class path is there. but it is not having the class i believe. 

Please find the 2 screenshots from SMA . 

April 7, 2017 - 7:46pm

can you check to see if the class ApiTrustTokenGenerator belong to a package?  If so, can you add the package under Java class to see if it makes any difference?

Please also try using the Connnector and Metadata wizard and see if that helps as well.

April 10, 2017 - 5:06am
Response to WaikeiKwok_GCS

Yes the class is the part of the package, I double checked . 

April 10, 2017 - 5:31pm
Response to RanabirB

Try search the class with fully qualified name.  For example, com.xyz.ApiTrustTokenGenerator.

Then try putting in the same fully qualified name of the class under Java class in the connect java rule.

July 26, 2017 - 11:51am
Response to WaikeiKwok_GCS

Hi Waikei,

As you have described I was able to find the classes using the fully qualified name. Now it is confirmed the jar has been loaded successfully in the server shared library.

But even though I see the classes have been loaded, when I try to use it in the Activity I am getting unresolved error. Why is the class not getting recognized and compiled?

April 10, 2017 - 8:18am

As per the Article in the PDN : https://pdn.pega.com/how-make-external-jar-files-and-classes-available

We need to load the PegaRules.XML file . Now in our WAS system this file does not exists. So we have to make the same and load it in WAS server. 

"

Classloader

At run-time, the Process Commander classloader automatically searchs the jar files located in the ext\lib directory, as well as the class files located in the ext\classes directory.

If third-party classes or jar files are placed in any other location, and if a "Class not found" error appears for a Process Commander class, then it may be necessary to enter the information about the third-party class into the classpath entry in the pegarules.xml classloader node. The path should be the same as that entered into the defaultPaths entry described above.

Please see the classloader node (classpath entry) and compiler node (defaultPaths entry) in the pegarules.xml File section of the Administration and Security Guide for more details on the nodes and entries.

If the content of jar files or class files used by the Process Commander classloader changes during execution, the classloader can be forced to use the new content by clicking on the appropriate refresh button of the Classloader Status page of PRMonitorServlet.

The full Process Commander classloader path appears in the console log during startup.

"

 

So anyone knows about PegaRules.XML File ?? how to create it ? 

April 13, 2017 - 7:41am

do we have to specify anywhere that which version of CUSTOMER ruleset we are using for jar . Because I did Import it three times with changes in the jar file to 010101 , 010102 and 010103 versions of the customer ruleset. but it is always taking the old jar . Even if I am overwriting the 010101 jar with new changes and restarting the server after clearing the cache the old jar is getting reflected. 

The old jar has been manually removed from the WAS server level too. Any Idea guys what is going wrong >??

April 18, 2017 - 5:38am

Ok , So Finally I am able to connect to the Jar file from Pega. And It did n't work through the Connect-java at all . I wrote a Java Script in a activity which is connecting to the Jar file seamlessly . 

Yes one more thing which is very very important, If you do have any certificates in your uploaded jar file then please be informed that the JREin which the Jar file was created should match with the JRE of your Pega application Server. 

In my case I was having a mismatch . My Jar file and the jks file and certificates were created using Sun(Oracle) jre. But in our application server we use the JRE of the IBM. So Boom there was a mismatch, The sol was to recreate the jks in IBM jre , which actually changes some Certificate format in IBM readable rather than Oracle Readable. and it worked. 

 

Actually I faced issue from starting of this to the every granular level of the implementation, but Finally it was done :) 

April 18, 2017 - 5:42am

Yes one more thing the Customer ruleset where you upload the Jar files have a serious Bug in 7.1.9 : Please do not upload the corrected jar in Customer:01-01-02 if the incorrect Jar has been already uploaded in Customer 01-01-01 . 

Rule Resolution Algorithm does not work in Customer Ruleset . I tested it in our application, It always takes the 01-01-01 version , may be it is mentioned somewhere (restricted) to use 01-01-01 version only but I did not find that . So always overwright the 01-01-01 version with the corrected jar file . (not recommendable but it works that way).