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

Lack of devservice license acceptance should suggests adding container-license-acceptance.txt to the right place in dev mode #44832

Open
yrodiere opened this issue Nov 29, 2024 · 0 comments

Comments

@yrodiere
Copy link
Member

yrodiere commented Nov 29, 2024

Description

If you forget to add a file in the classpath to accept the license of a devservice, you get an error like this:

2024-11-29 17:07:36,349 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor#launchDatabases threw an exception: java.lang.RuntimeException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mcr.microsoft.com/mssql/server:2022-latest
        at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.startDevDb(DevServicesDatasourceProcessor.java:368)
        at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.launchDatabases(DevServicesDatasourceProcessor.java:121)
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mcr.microsoft.com/mssql/server:2022-latest
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:351)
        at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
        at io.quarkus.devservices.mssql.deployment.MSSQLDevServicesProcessor$1.startDatabase(MSSQLDevServicesProcessor.java:73)
        at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.startDevDb(DevServicesDatasourceProcessor.java:294)
        ... 11 more
Caused by: java.lang.IllegalStateException: The image mcr.microsoft.com/mssql/server:2022-latest requires you to accept a license agreement. Please place a file at the root of the classpath named container-license-acceptance.txt, e.g. at src/test/resources/container-license-acceptance.txt. This file should contain the line:
  mcr.microsoft.com/mssql/server:2022-latest
        at org.testcontainers.utility.LicenseAcceptance.assertLicenseAccepted(LicenseAcceptance.java:30)
        at org.testcontainers.containers.MSSQLServerContainer.configure(MSSQLServerContainer.java:77)
        at io.quarkus.devservices.mssql.deployment.MSSQLDevServicesProcessor$QuarkusMSSQLServerContainer.configure(MSSQLDevServicesProcessor.java:103)
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
        ... 14 more

        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:355)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:272)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:62)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:89)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:428)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:55)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor#launchDatabases threw an exception: java.lang.RuntimeException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mcr.microsoft.com/mssql/server:2022-latest
        at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.startDevDb(DevServicesDatasourceProcessor.java:368)
        at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.launchDatabases(DevServicesDatasourceProcessor.java:121)
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mcr.microsoft.com/mssql/server:2022-latest
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:351)
        at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
        at io.quarkus.devservices.mssql.deployment.MSSQLDevServicesProcessor$1.startDatabase(MSSQLDevServicesProcessor.java:73)
        at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.startDevDb(DevServicesDatasourceProcessor.java:294)
        ... 11 more
Caused by: java.lang.IllegalStateException: The image mcr.microsoft.com/mssql/server:2022-latest requires you to accept a license agreement. Please place a file at the root of the classpath named container-license-acceptance.txt, e.g. at src/test/resources/container-license-acceptance.txt. This file should contain the line:
  mcr.microsoft.com/mssql/server:2022-latest
        at org.testcontainers.utility.LicenseAcceptance.assertLicenseAccepted(LicenseAcceptance.java:30)
        at org.testcontainers.containers.MSSQLServerContainer.configure(MSSQLServerContainer.java:77)
        at io.quarkus.devservices.mssql.deployment.MSSQLDevServicesProcessor$QuarkusMSSQLServerContainer.configure(MSSQLDevServicesProcessor.java:103)
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
        ... 14 more

        at io.quarkus.builder.Execution.run(Execution.java:124)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:161)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:351)
        ... 9 more
Caused by: java.lang.RuntimeException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mcr.microsoft.com/mssql/server:2022-latest
        at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.startDevDb(DevServicesDatasourceProcessor.java:368)
        at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.launchDatabases(DevServicesDatasourceProcessor.java:121)
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQcutor.java:1594)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mcr.microsoft.com/mssql/server:2022-latest
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:351)
        at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
        at io.quarkus.devservices.mssql.deployment.MSSQLDevServicesProcessor$1.startDatabase(MSSQLDevServicesProcessor.java:73)
        at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.startDevDb(DevServicesDatasourceProcessor.java:294)
        ... 11 more
Caused by: java.lang.IllegalStateException: The image mcr.microsoft.com/mssql/server:2022-latest requires you to accept a license agreement. Please place a file at the root of the classpath named container-license-acceptance.txt, e.g. at src/test/resources/container-license-acceptance.txt. This file should contain the line:
  mcr.microsoft.com/mssql/server:2022-latest
        at org.testcontainers.utility.LicenseAcceptance.assertLicenseAccepted(LicenseAcceptance.java:30)
        at org.testcontainers.containers.MSSQLServerContainer.configure(MSSQLServerContainer.java:77)
        at io.quarkus.devservices.mssql.deployment.MSSQLDevServicesProcessor$QuarkusMSSQLServerContainer.configure(MSSQLDevServicesProcessor.java:103)
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
        ... 14 more

That's fair.

Now, what's problematic is that putting the license acceptance in src/test/resources/container-license-acceptance.txt will not make it work in dev mode, because the test classpath is not available in dev mode.

It makes sense when you think about it, but the error message is still confusing. Ideally it would not suggest something that will not work.

Implementation ideas

Maybe we could catch such exception and replace the message with one of our own, one that takes into account the run mode?

@yrodiere yrodiere changed the title Lack of license acceptance should suggests adding container-license-acceptance.txt to the right place in dev mode Lack of devservice license acceptance should suggests adding container-license-acceptance.txt to the right place in dev mode Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant