Question

how to use external java libraries in java code where should i place my external jar files

I have to use external java libraries like apache-poi 3.15 and some other (pega 7.2 has poi 3.11 version) where should i place this jars in server

I have tried below scenarios:

  1. I have placed in prweb\web-inf\lib folder but not able to access class, when save java code getting class not found errors
  2. I have also imported jar using Application-> Distribution-> import from landing page but not able to access these classes in my my code

Where should i place the jar files if i am using external java libraries in pega 7.2?

**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.

Comments

Keep up to date on this post and subscribe to comments

April 14, 2017 - 7:29am

You should try option 2 first, but sometimes if your jar is conflicting with pega OOTB jars (e.g., same jar but different version), you should try to include jar in the app server specific location, e.g., for tomcat under /lib directory.

August 8, 2017 - 2:45pm
Response to KevinZheng_GCS

Hi Kevin,

I am facing the conflict issue .Could you please let me know how we can resolve?

Thanks,

Lalit

 

August 8, 2017 - 9:28pm

For your external JARs to become readily available for the PRPC ClassLoader both at compiletime and runtime you will need to import it via the "Application > Distribution > Import" wizard. 

Quick questions - 

1) Was the server restarted after you imported the external JARs to the PRPC database table?

2) When are you facing this issue? Is it at compiletime (when your are trying to save a rule referencing the external libraries) OR is it at runtime (when you are execute/run the saved rule referring the external libraries)?

3) Also what is the ERROR/Exception you are seeing? Is it ClassNotfoundException or NoClassDefFoundError? Can you paste the complete Exception Stack trace here. 

August 8, 2017 - 9:46pm
Response to @nkur.das_GCS

Hello,

Thanks for the reply .

Yes i have restarted the server but still getting the abstract method error and when i debug it looks like pega is picking up pega engine code in which method is not defined.

getting this in log file . looks like some conflict with this jar google-http-client-1.22.0.jar

Caused by: java.lang.AbstractMethodError: org.jose4j.base64url.internal.apache.commons.codec.binary.BaseNCodec.encode([BIILorg/jose4j/base64url/internal/apache/commons/codec/binary/BaseNCodec$Context;)V

at org.jose4j.base64url.internal.apache.commons.codec.binary.BaseNCodec.encode(BaseNCodec.java:375)

at org.jose4j.base64url.internal.apache.commons.codec.binary.BaseNCodec.encodeToString(BaseNCodec.java:318)

at org.jose4j.base64url.Base64Url.base64UrlEncode(Base64Url.java:62)

at org.jose4j.base64url.Base64Url.encode(Base64Url.java:97)

at org.jose4j.keys.X509Util.base64urlThumbprint(X509Util.java:115)

at org.jose4j.keys.X509Util.x5t(X509Util.java:94)

at org.jose4j.keys.resolvers.X509VerificationKeyResolver.<init>(X509VerificationKeyResolver.java:57)

at org.jose4j.keys.resolvers.X509VerificationKeyResolver.<init>(X509VerificationKeyResolver.java:72)

at com.ab.coreapi.common.security.JwtHelper.verifyJwt(JwtHelper.java:111)

at com.pegarules.generated.activity.sh_action_test_6dbdad62f02787f0cf5d048e5aa81f92.step2_circum0(sh_action_test_6dbdad62f02787f0cf5d048e5aa81f92.java:233)

at com.pegarules.generated.activity.sh_action_test_6dbdad62f02787f0cf5d048e5aa81f92.perform(sh_action_test_6dbdad62f02787f0cf5d048e5aa81f92.java:88)

at com.pega.pegarules.session.internal.mgmt.Executable.doActivity(Executable.java:3553)

at com.pega.pegarules.session.internal.mgmt.Executable.doAction(Executable.java:3286)

Thanks,

Lalit