quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

Adding a Java class to Kotlin module breaks Quarkus start #39404

Open ZorinAnton opened 8 months ago

ZorinAnton commented 8 months ago

Describe the bug

I need to start Quarkus from main function:

@QuarkusMain
class App : QuarkusApplication{

    override fun run(vararg args: String?): Int {
        println("quarkus running")
        Quarkus.waitForExit()
        return 0
    }
}

fun main() {
    val app:Class<App>? = App::class.java
    Quarkus.run(app)
    Quarkus.asyncExit()
}

This works fine, but if I add a java class (even empty) I get The supplied 'main-class' value of 'App' does not correspond to either a fully qualified class name or a matching 'name' field of one of the '@QuarkusMain' annotations It appears to me that Kotlin annotations don't get processed in this case.

Expected behavior

Start without errors

Actual behavior

Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.deployment.steps.MainClassBuildStep#mainClassBuildStep threw an exception: java.lang.IllegalArgumentException: The supplied 'main-class' value of 'App' does not correspond to either a fully qualified class name or a matching 'name' field of one of the '@QuarkusMain' annotations
    at io.quarkus.deployment.steps.MainClassBuildStep.mainClassBuildStep(MainClassBuildStep.java:429)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
    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.run(EnhancedQueueExecutor.java:2513)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
    at java.base/java.lang.Thread.run(Thread.java:833)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)

    at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:334)
    at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:251)
    at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:60)
    at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:112)
    at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:433)
    at io.quarkus.deployment.dev.IDEDevModeMain.accept(IDEDevModeMain.java:71)
    at io.quarkus.deployment.dev.IDEDevModeMain.accept(IDEDevModeMain.java:28)
    at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
    at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
    at io.quarkus.bootstrap.IDELauncherImpl.launch(IDELauncherImpl.java:93)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at io.quarkus.launcher.QuarkusLauncher.launch(QuarkusLauncher.java:56)
    at io.quarkus.runtime.Quarkus.launchFromIDE(Quarkus.java:101)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:88)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
    at AppKt.main(App.kt:26)
    at AppKt.main(App.kt)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.deployment.steps.MainClassBuildStep#mainClassBuildStep threw an exception: java.lang.IllegalArgumentException: The supplied 'main-class' value of 'App' does not correspond to either a fully qualified class name or a matching 'name' field of one of the '@QuarkusMain' annotations

How to Reproduce?

quarkus-kotlin.zip

Output of uname -a or ver

Microsoft Windows [Version 10.0.22631.3155]

Output of java -version

java version "17.0.2" 2022-01-18 LTS Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86) Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)

Quarkus version or git rev

3.8.1

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

Gradle 8.6

Additional information

If I perform the same task using Java it works, but kotlin annotations are still don't seem to get recognized. Kotlin entities are not visible and I get jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type MetaRepoService and qualifiers [@Default] until I define an entity with Java.

quarkus-bot[bot] commented 8 months ago

/cc @geoand (kotlin)

geoand commented 8 months ago

It seems that the addition of the java source set results in Quarkus not including the Kotlin classes it it's index (when launching from the IDE). @aloubyansky any ideas of how to address it?