Expand my Community achievements bar.

Join expert-led, customer-led sessions on Adobe Experience Manager Assets on August 20th at our Skill Exchange.
SOLVED

AEM Cloud Build pipeline fails due to Code Scanner (Jacoco) plugin version does not support Multi-Release Jars

Avatar

Level 2

Hello,

 

For our project we require a connection to be made to a SFTP server. We managed to get this to work locally, OSGI picks the newly included Jsch JAR and we where able to establish a SFTP connection and perform the required operations.

However, The AEMaaCS(2025.3.19823.20250304T101418Zbuild pipeline can build the project successfully, but the code scanner that runs after the build fails with the following error:

 

==================

[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.12:report (default-cli) on project palfinger.core: An error has occurred in JaCoCo report generation.: Error while creating report: Error while analyzing /build_root/build/palfingeragprogram-p152172-uk33244/core/target/classes/jsch-0.2.23.jar@META-INF/versions/9/com/jcraft/jsch/JavaVersion.class with JaCoCo 0.8.12.202403310830/dbfb6f2. Can't add different class with same name: com/jcraft/jsch/JavaVersion

==================

 

This is because JaCoCo which is used for Code scanning by Build Pipeline does not support the multi release jars so it finds duplicate classes as it scans all the classes of all included releases.

In this SatckOverflow thread, the accepted answer seems to provide the solution: https://stackoverflow.com/questions/47664723/jacoco-and-mr-jars

 

  • To give some background information, there are the changes we made to our project
  • Updated Java version to 17 (So we can update the BND plugin)
  • Updated bnd plugin to version 7.1.0 (so it supports Multi Release Jars)
  • Added Jsch Dependency in POM:

<dependency>

<groupId>com.github.mwiede</groupId>

<artifactId>jsch</artifactId>

<version>0.2.23</version>

</dependency>

  • Added the following to the BND Configuration section of the core pom: -includeresource: jsch-[0-9.]*.jar;lib:=true

Does anyone encountered similar issue and found the solution? 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 8

You can exclude this jar from jacoco execution by adding -

<exclude>jsch-0.2.23.jar</exclude> 

in the jacoco plugin configuration of your pom.xml

			<plugin>
				<groupId>org.jacoco</groupId>
				<artifactId>jacoco-maven-plugin</artifactId>
				<version>${jacoco.version}</version>
				<configuration>
					<excludes>
						<!-- Exclude jar -->
						<exclude>*.jar</exclude>
					</excludes>
				</configuration>
				<executions>
					<execution>
						<id>jacoco-initialize</id>
						<goals>
							<goal>prepare-agent</goal>
						</goals>
					</execution>
					<execution>
						<id>jacoco-site</id>
						<phase>package</phase>
						<goals>
							<goal>report</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

 

View solution in original post

5 Replies

Avatar

Correct answer by
Level 8

You can exclude this jar from jacoco execution by adding -

<exclude>jsch-0.2.23.jar</exclude> 

in the jacoco plugin configuration of your pom.xml

			<plugin>
				<groupId>org.jacoco</groupId>
				<artifactId>jacoco-maven-plugin</artifactId>
				<version>${jacoco.version}</version>
				<configuration>
					<excludes>
						<!-- Exclude jar -->
						<exclude>*.jar</exclude>
					</excludes>
				</configuration>
				<executions>
					<execution>
						<id>jacoco-initialize</id>
						<goals>
							<goal>prepare-agent</goal>
						</goals>
					</execution>
					<execution>
						<id>jacoco-site</id>
						<phase>package</phase>
						<goals>
							<goal>report</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

 

Avatar

Level 2

Hi @narendiran_ravi 

This works flawlessly, thank you.

We do now run into another issue where we are not able to connect to any SFTP Server.

We tried the following:

1. Enabled Advanced Networking (As AEM blocks ports other than 80 and 443 by default)
2. Set Port Forwarding from port 30022 to 22 for the domain of the SFTP server we want to connect to.
3. We set an environment variable to ensure AEM uses port 30022 to connect to the SFTP server
4. We verified this by checking the logs:

SFTPServiceImpl Connecting to SFTP server: {{host-redacted}}30022 
SFTPServiceImpl Failed to connect to SFTP server: timeout: socket is not established

We this as the code:

JSch jsch = new JSch();
Sesson session = jsch.getSession("{{username-redacted}}", "{{host-redacted}}", 30022);
session.setPassword("{{password-redacted");

Properties config = new Properties();
config.put("StrictHostKeyChecking", "no"); // For development - consider changing for production
session.setConfig(config);
session.setTimeout(30000);
log.info("Connecting to SFTP server: {}:{}", "{{host-redacted}}", "30022");
session.connect();



Trying this locally (but then with port 22) it works just fine. Do we need to change anything in JSch or the JSch Session object to ensure the Advanced networking port forwarding is being used?

Thank you in advance!

Avatar

Level 8

Hi @DennisAtDept ,

You should connect AEM_PROXY_HOST via System.getenv().getOrDefault("AEM_PROXY_HOST", "proxy.tunnel"). ex: 

jsch.getSession(userName, PROXY_HOST, YOUR_PORT);


AEMaaCS will pick your host from the below rules and it will make a connection via defaultHost

"portForwards": [
        {
            "name": "sftp.example.com",
            "portDest": 22,
            "portOrig": 30022
        }
    ]

 Refer -https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/security/configu... 

Avatar

Level 2

Hi @narendiran_ravi 

Thanks! This works wonderfully.

We never encountered this behavior before when using Advanced Networking to route traffic (both port-forwarding and egress IP) using the default Java HttpClient.
I guess Adobe does automatically applies the correct proxy when this is used.




@narendiran_ravi thanks a lot, marking this as accepted solution.