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.20250304T101418Z) build 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
<dependency>
<groupId>com.github.mwiede</groupId>
<artifactId>jsch</artifactId>
<version>0.2.23</version>
</dependency>
Does anyone encountered similar issue and found the solution?
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
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>
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>
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!
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
}
]
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.
Views
Likes
Replies
Views
Likes
Replies