This issue has been created
There is 1 update.
 
 
XWiki Commons / cid:jira-generated-image-avatar-fc6beb74-77bd-4973-8388-dca0364d0a98 XCOMMONS-3799 Open

The artifact id of a core extension found from a pom.xml embedded in a JAR is not resolved

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-ff132c24-845b-4ee7-9c2d-f2767f222502 Thomas Mortagne created this issue on 18/Sep/26 11:42
 
Summary: The artifact id of a core extension found from a pom.xml embedded in a JAR is not resolved
Issue Type: cid:jira-generated-image-avatar-fc6beb74-77bd-4973-8388-dca0364d0a98 Bug
Affects Versions: 17.10.13
Assignee: Unassigned
Components: Extension
Created: 18/Sep/26 11:42
Priority: cid:jira-generated-image-static-major-2b25a717-ad9a-49ae-899c-e310e467c81e Major
Reporter: Thomas Mortagne
Description:

When a JAR of the classpath has no .xed descriptor, the core extension scanner falls back on the META-INF/maven/<groupId>/<artifactId>/pom.xml embedded in the JAR (MavenExtensionScanner#parseMavenPom). The groupId and the version found there are resolved (MavenUtils#resolveGroupId and MavenUtils#resolveVersion expand Maven properties and fall back on the parent), but the artifact id is used as it is in ModelConverter#convertToExtension:

String groupId = MavenUtils.resolveGroupId(model);
String artifactId = model.getArtifactId();
String type = this.converter.mavenPackagingToExtensionType(model.getPackaging());
String version = MavenUtils.resolveVersion(model);

As a result, a JAR whose embedded pom.xml is the raw (not interpolated) one and contains a property in its <artifactId> is registered as a core extension with an invalid id. XWiki then tries to resolve that id on each of the configured extension repositories at each startup, and logs an error for each of them.

For example netty-tcnative-boringssl-static native JARs (the ones with a linux-x86_64, osx-aarch_64, etc. classifier) embed a pom.xml containing <artifactId>${project.artifactId}</artifactId>, which leads to:

ERROR aultExtensionRepositoryManager - Unexpected error when trying to find extension [io.netty:${project.artifactId}/2.0.81.Final] in repository [maven-xwiki:maven:https://nexus-snapshots.xwiki.org/repository/public-proxy {}]
org.xwiki.extension.ResolveException: Failed to resolve artifact [io.netty:${project.artifactId}:jar:2.0.81.Final] descriptor
[...]
Caused by: org.apache.http.client.HttpResponseException: status code: 400, reason phrase: Invalid repository path (400)

Note that adding an equivalent of MavenUtils#resolveGroupId for the artifact id is not enough: ${project.artifactId} is self referencing, so it cannot be resolved from the model alone. But the right value is available twice next to the descriptor:

  • in the path of the descriptor itself, META-INF/maven/<groupId>/<artifactId>/pom.xml (the scanner builds the URL it parses from that path)
  • in the pom.properties that Maven generates in the same folder, which contains the resolved groupId, artifactId and version

It would also be safer to refuse to send an extension id which still contains an unresolved property to the remote repositories, instead of producing an error for each of them at each startup.

 
 

1 update

 
cid:jira-generated-image-avatar-ff132c24-845b-4ee7-9c2d-f2767f222502 Changes by Thomas Mortagne on 18/Sep/26 11:42
 
Assignee: Thomas Mortagne