Loading
ただいま大変多くのお問い合わせをいただいており、ご連絡までにお時間を頂戴しております続きを読む

MUnit tests in MuleSoft projects using the SAP Connector may fail when the SAP native libraries (sapjco3.jar, sapidoc3.jar, libsapjco3.so) aren't found at the path specified in the munit-tests Maven profile

公開日: Jul 3, 2026
説明

When running MUnit tests in a MuleSoft project that uses the SAP Connector, tests may fail because the SAP native libraries (sapjco3.jar, sapidoc3.jar, libsapjco3.so) are not found at the path specified in the munit-tests Maven profile.
The root cause has two contributing factors:

  1. Library Path Mismatch (Build Timing Issue): The munit-tests profile's sap.path points to ${project.basedir}/src/main/mule/lib, but the SAP libraries are copied by the maven-dependency-plugin to ${project.build.directory}/lib during the process-sources phase. Since MUnit tests execute before the libraries are copied to the target/ directory, Maven cannot resolve the SAP dependencies.
  2. SAP Connector Initializes Even When Mocked: Unlike most MuleSoft connectors, the SAP Connector initializes its configuration at startup even when the external service is mocked in MUnit. This means simply mocking the SAP service is not sufficient to avoid the issue — the connector still attempts to load the native libraries at startup.

This results in errors such as:

Could not find artifact com.sap.conn.idoc:com.sap.conn.idoc.sapidoc3:jar:3.1.4 at specified path /home/vsts/work/1/s/src/main/mule/lib/sapidoc3.jar

dependency: com.sap.conn.jco:com.sap.conn.jco.sapjco3:jar:3.1.12 (system)
解決策

Because the SAP Connector initializes its configuration regardless of mocking, the fix requires a two-step build approach:
Run the following commands in order:

Step 1 – Build Everything First

Run a full Maven build first to ensure all SAP libraries are copied to ${project.build.directory}/lib before any tests execute.

mvn clean package -DskipTests

Step 2 – Update the munit-tests Profile and Run Tests

Update the sap.path property in the munit-tests profile in your pom.xml to point to the correct target/lib directory, then run:

mvn test -P munit-tests

This aligns the dependency path with the actual location where the SAP libraries are copied during the build process.

ナレッジ記事番号

005388152

 
読み込み中
Salesforce Help | Article