Coverage Reporting for Embedded Java Libraries

Applications that embed JAR/WAR components may not show per‑component coverage unless multi‑component mode is correctly configured.

Problem

When Java applications include multiple embedded components—such as shared libraries packaged inside EAR/WAR files—coverage may not appear for those components because the agent cannot attribute coverage without multi‑component configuration.

Solution

circle-info

Coverage cannot be accurately reported if two different versions of the same component run within the same deployed application.

1

Prerequisites

Make sure:

  1. Each component is built in its own pipeline (unique Build Session ID).

  2. Each component contains its specific buildSessionId.txt inside the packaged JAR/WAR - Build step uses includeResources: true (or leave it out—the default is true)..

  3. Final application (EAR/WAR) preserves embedded artifacts unchanged.

2

Required Runtime Configuration

Add these JVM flags to the application under test:

-Dsl.multipleComponents=true \
-Dsl.webappLocation=<absolute-path-to-deployment-directory>

According to your deployment methodology:

  • If the application is deployed in an exploded form, the sl.webappLocation property must point to the exploded directory.

  • If the application is not exploded, sl.webappLocation should instead point to the directory that contains the EAR or WAR file, rather than the file itself.

If your embedded libraries use package names outside the main application’s namespace, you must explicitly include them:

-Dsl.includes=com.company.app.*,com.company.lib.*
circle-check

Common issues

  • Only top-level app visible in Live Agents → sl.multipleComponents=true not set

  • Agent warns about components not detected → Wrong sl.webappLocation

  • Component shows 0% coverage → buildSessionId.txt missing

Last updated

Was this helpful?