Skip to main content
Krzysztof Zimny ha preguntado en * MuleSoft *

Hi, the current version of the SAP JCo connector enforces the name of the containing jar at runtime. 

This will lead to exceptions, if it doesn't match the name (sapjco3.jar).

JCo initialization failed with java.lang.ExceptionInInitializerError: Illegal JCo archive "com.sap.conn.jco.sapjco3-3.1.13.jar".

It is not allowed to rename or repackage the original archive "sapjco3.jar".

Caused by: java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.ExceptionInInitializerError:

Illegal JCo archive "com.sap.conn.jco.sapjco3-3.1.13.jar". It is not allowed to rename or repackage the original archive "sapjco3.jar".

 

This is a known issue described in the documentation: 

-

https://docs.mulesoft.com/sap-connector/latest/sap-connector-troubleshooting#jco-renaming-conflicts

 

-

https://help.salesforce.com/s/articleView?id=001117810&type=1

 

 

To resolve this error, the maven-shade-plugin should be added to pom.xml which relocate (rewrite) packages to avoid classpath conflicts. Unfortunately, this approach works only at runtime, but not for MUnit tests. Does anyone know how to configure the pom.xml file for the MUnit tests?  

 

5 respuestas
  1. 20 ago, 12:55

    There is a solution.

    • Define two profiles in the pom.xml file.
    • Profile 1: runtime -> for the runtime environment, Profile 2: test -> for MUnit tests.
    • Load the JCo dependencies for the runtime profile via Maven and use the maven-shade-plugin.
    • For the MUnit tests, the JCo files (sapjco3.jar, sapidoc3.jar, sapjco3.dll, and libsapjco3.so) must be referenced from or downloaded from an artifact repository. They should then be referenced using the attributes <scope>system</scope> and <systemPath>${saplibs}/sapjco3.jar</systemPath>.
    • This solution works both locally in Anypoint Studio and on the server side through a CI/CD pipeline.
0/9000