Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@QuarkusTest fails when Nexus repository requires login (401 Unauthorized) (does not use existing Maven security credentials) #46260

Closed
kurtlenfesty opened this issue Feb 13, 2025 · 6 comments · Fixed by #46271

Comments

@kurtlenfesty
Copy link

kurtlenfesty commented Feb 13, 2025

Describe the bug

Our Nexus repository requires a login/password. This is set in the ~/.m2/settings.xml with an additional settings-security.xml. This is a standard maven setup for security. See https://maven.apache.org/guides/mini/guide-encryption.html for Maven's security setup.

This works fine for Quarkus builds up to version 3.17.8. For Quarkus version 3.18.0 and above, when running tests annotated with @QuarkusTest or @QuarkusIntegrationTest, the credentials stored in the Maven settings are ignored with a 401 Unauthorized when the test tries to bring any dependencies required to run Quarkus tests.

Tested on quarkus-quickstarts/getting-started, found at: https://github.com/quarkusio/quarkus-quickstarts/tree/main/getting-started

Attached are 4 attached files:

  • 2025-02-13_Quarkus-3.18.3_quarkus-quickstarts_getting-started__mvn_clean_install.log - build with Quarkus 3.18.3 version
    • Note that the build fails with caused by: org.eclipse.aether.resolution.ArtifactResolutionException: The following artifacts could not be resolved: io.quarkus:quarkus-rest-kotlin:jar:3.18.3 (absent): Could not transfer artifact io.quarkus:quarkus-rest-kotlin:jar:3.18.3 from/to releases (https://nexus.[REDACTED]/repository/maven-public/): status code: 401, reason phrase: Unauthorized (401)
  • 2025-02-13_Quarkus-3.18.1_quarkus-quickstarts_getting-started__mvn_clean_install.log - build with Quarkus 3.18.1. Same failure.
  • 2025-02-13_Quarkus-3.17.8_quarkus-quickstarts_getting-started__mvn_clean_install.log - build with Quarkus 3.17.8. This build succeeds.
  • 2025-02-13_Quarkus-3.15.1_quarkus-quickstarts_getting-starte__mvn_clean_install.log - build with Quarkus 3.15.1. This build succeeds

2025-02-13_Quarkus-3.18.1_quarkus-quickstarts_getting-started__mvn_clean_install.log
2025-02-13_Quarkus-3.18.3_quarkus-quickstarts_getting-started__mvn_clean_install.log
2025-02-13_Quarkus-3.17.8_quarkus-quickstarts_getting-started__mvn_clean_install.log
2025-02-13_Quarkus-3.15.1_quarkus-quickstarts_getting-starte__mvn_clean_install.log

Expected behavior

The project should build seamlessly with Maven configured with user/password for Nexus, as it has done up to version 3.17.8.

Actual behavior

The project fails to build after Quarkus version 3.17.8 (as tested version 3.18.1 or after). The stack trace includes the following:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.acme.getting.started.GreetingResourceTest
Downloading from releases: https://nexus.[REDACTED]/repository/maven-public/io/quarkus/quarkus-rest-kotlin/3.18.3/quarkus-rest-kotlin-3.18.3.jar
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 1, Time elapsed: 1.659 s <<< FAILURE! -- in org.acme.getting.started.GreetingResourceTest
[ERROR] org.acme.getting.started.GreetingResourceTest.testHelloEndpoint -- Time elapsed: 0.018 s <<< ERROR!
java.lang.RuntimeException: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for org.acme:getting-started::jar:1.0.0-SNAPSHOTnull
	at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:611)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:695)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for org.acme:getting-started::jar:1.0.0-SNAPSHOTnull
	at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModelForWorkspace(BootstrapAppModelFactory.java:280)
	at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:219)
	at io.quarkus.bootstrap.app.QuarkusBootstrap.bootstrap(QuarkusBootstrap.java:138)
	at io.quarkus.test.junit.AbstractJvmQuarkusTestExtension.createAugmentor(AbstractJvmQuarkusTestExtension.java:196)
	at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:190)
	at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:578)
	at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:628)
	... 1 more
Caused by: io.quarkus.bootstrap.resolver.maven.DeploymentInjectionException: Failed to resolve artifact io.quarkus:quarkus-rest-kotlin:jar:3.18.3
	at io.quarkus.bootstrap.resolver.maven.ApplicationDependencyTreeResolver.resolve(ApplicationDependencyTreeResolver.java:700)
	at io.quarkus.bootstrap.resolver.maven.ApplicationDependencyTreeResolver.collectConditionalDependencies(ApplicationDependencyTreeResolver.java:547)
	at io.quarkus.bootstrap.resolver.maven.ApplicationDependencyTreeResolver.visitRuntimeDependency(ApplicationDependencyTreeResolver.java:467)
	at io.quarkus.bootstrap.resolver.maven.ApplicationDependencyTreeResolver.visitRuntimeDependencies(ApplicationDependencyTreeResolver.java:419)
	at io.quarkus.bootstrap.resolver.maven.ApplicationDependencyTreeResolver.resolve(ApplicationDependencyTreeResolver.java:193)
	at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.buildAppModel(BootstrapAppModelResolver.java:392)
	at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.doResolveModel(BootstrapAppModelResolver.java:325)
	at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.resolveManagedModel(BootstrapAppModelResolver.java:206)
	at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModelForWorkspace(BootstrapAppModelFactory.java:269)
	... 7 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: The following artifacts could not be resolved: io.quarkus:quarkus-rest-kotlin:jar:3.18.3 (absent): Could not transfer artifact io.quarkus:quarkus-rest-kotlin:jar:3.18.3 from/to releases (https://nexus.[REDACTED]/repository/maven-public/): status code: 401, reason phrase: Unauthorized (401)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:473)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:261)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:243)
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:278)
	at io.quarkus.bootstrap.resolver.maven.ApplicationDependencyTreeResolver.resolve(ApplicationDependencyTreeResolver.java:694)
	... 15 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact io.quarkus:quarkus-rest-kotlin:jar:3.18.3 from/to releases (https://nexus.[REDACTED]/repository/maven-public/): status code: 401, reason phrase: Unauthorized (401)
	at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:44)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:417)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:260)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:537)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:449)
	... 19 more
Caused by: org.apache.http.client.HttpResponseException: status code: 401, reason phrase: Unauthorized (401)
	at org.eclipse.aether.transport.http.HttpTransporter.handleStatus(HttpTransporter.java:618)
	at org.eclipse.aether.transport.http.HttpTransporter.execute(HttpTransporter.java:487)
	at org.eclipse.aether.transport.http.HttpTransporter.implGet(HttpTransporter.java:434)
	at org.eclipse.aether.spi.connector.transport.AbstractTransporter.get(AbstractTransporter.java:64)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:482)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:414)
	... 22 more

How to Reproduce?

Tested on quarkus-quickstarts/getting-started, found at: https://github.com/quarkusio/quarkus-quickstarts/tree/main/getting-started

To reproduce:

  1. Set up maven settings for a password protected Nexus repository, following https://maven.apache.org/guides/mini/guide-encryption.html
  2. Try to build the project -- this will fail
  3. Change the pom.xml so that <quarkus.platform.version>3.18.3</quarkus.platform.version> is now:
  • <quarkus.platform.version>3.17.8</quarkus.platform.version>
  • This build will succeed

quarkus-quickstarts_getting-started_as-of-2025-02-13.zip

Output of uname -a or ver

Linux my-machine-name 6.13.0-1-MANJARO #1 SMP PREEMPT_DYNAMIC Mon, 20 Jan 2025 04:45:43 +0000 x86_64 GNU/Linux

Output of java -version

openjdk version "21.0.3" 2024-04-16 LTS OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode, sharing)

Quarkus version or git rev

3.18.3

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.7 (8b094c9513efc1b9ce2d952b3b9c8eaedaf8cbf0) Maven home: /home/the-user/maven/apache-maven-3.9.7 Java version: 21.0.3, vendor: Eclipse Adoptium, runtime: /home/the-user/.sdkman/candidates/java/21.0.3-tem Default locale: en_CA, platform encoding: UTF-8 OS name: "linux", version: "6.13.0-1-manjaro", arch: "amd64", family: "unix"

Additional information

No response

Copy link

quarkus-bot bot commented Feb 13, 2025

/cc @geoand (kotlin), @quarkusio/devtools (maven), @sberyozkin (security)

@geoand
Copy link
Contributor

geoand commented Feb 13, 2025

cc @aloubyansky @Ladicek

@Ladicek
Copy link
Contributor

Ladicek commented Feb 14, 2025

I can reproduce this. If the password is written in settings.xml in the clear text, it works, but if it's encrypted, it fails. Also, Quarkus 3.18.0 seems to work just fine (@kurtlenfesty if you could confirm that, that would be great!), so the issue seems to have been introduced in 3.18.1. I didn't check yet, but it seems very likely it's my fault :-) Will continue digging.

@Ladicek
Copy link
Contributor

Ladicek commented Feb 14, 2025

Fix is in #46271

@kurtlenfesty
Copy link
Author

Thanks @Ladicek. Actually, for 3.18.0 I couldn't get it to build at all. Perhaps because the backing nexus repository doesn't have that version or what. I've attached the logs for the build. But since the real problem was in 3.18.1 to 3.18.3, I reported those versions.

2025-02-14_Quarkus-3.18.0_quarkus-quickstarts_getting-started__mvn_clean_install.log

@Ladicek
Copy link
Contributor

Ladicek commented Feb 14, 2025

OK, I have no idea why that would happen, but at least it's not the same failure, that would be disappointing :-)

@quarkus-bot quarkus-bot bot added this to the 3.21 - main milestone Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants