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

Quarkus cant be launched with Main-Class with gradle #10602

Closed
hosseinmp76 opened this issue Jul 9, 2020 · 13 comments
Closed

Quarkus cant be launched with Main-Class with gradle #10602

hosseinmp76 opened this issue Jul 9, 2020 · 13 comments
Assignees
Labels
area/gradle Gradle triage/invalid This doesn't seem right

Comments

@hosseinmp76
Copy link

hosseinmp76 commented Jul 9, 2020

when I want to start quarkus with a gradle based project I get this is the exception:

Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at io.quarkus.launcher.QuarkusLauncher.launch(QuarkusLauncher.java:50)
	at io.quarkus.runtime.Quarkus.launchFromIDE(Quarkus.java:93)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:79)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
	at edu.sharif.surveyBackend.cli.Main.main(Main.java:12)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.launcher.QuarkusLauncher.launch(QuarkusLauncher.java:47)
	... 4 more
Caused by: java.lang.RuntimeException: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for null
	at io.quarkus.bootstrap.IDELauncherImpl.launch(IDELauncherImpl.java:30)
	... 9 more
Caused by: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for null
	at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:313)
	at io.quarkus.bootstrap.app.QuarkusBootstrap.bootstrap(QuarkusBootstrap.java:157)
	at io.quarkus.bootstrap.IDELauncherImpl.launch(IDELauncherImpl.java:27)
	... 9 more
Caused by: io.quarkus.bootstrap.BootstrapException: Failed to determine the Maven artifact associated with the application /home/hosseinmp76/Documents/eclipse-workspace/survey-backend/bin/main
	at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:253)
	... 11 more

I track the problem and I found in BootstrapAppModelFactory class at line 211 in method createBootstrapMavenContext it can't find pom.xml (its gradle project) so it make a new BootstrapMavenContext. and it uses resolveCurrentProject() that itself calls
LocalProject.loadWorkspace and it returns null because:

final Path currentProjectPom = ctx.getCurrentProjectPomOrNull();
        if (currentProjectPom == null) {
            return null;
        }

I have this problem with 1.5.0 & 1.5.2 & 1.6.0 versions.
I can publish my project if you can't reproduce the bug.

when use gradle to start (I mean removing @ QuarkusMain ) the projects starts with ./gradlew quarkusDev with no problem but after using this approach despite the the above problem when I use ./gradlew quarkusDev the projects start normally but when I use browser I get this exception:

java.lang.IllegalStateException: No CDI container is available
	at io.quarkus.arc.impl.ArcCDIProvider.getCDI(ArcCDIProvider.java:27)
	at javax.enterprise.inject.spi.CDI.current(CDI.java:64)
	at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2.handle(HttpSecurityRecorder.java:56)
	at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2.handle(HttpSecurityRecorder.java:49)
	at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1034)
	at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131)
	at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133)
	at io.quarkus.vertx.http.runtime.cors.CORSFilter.handle(CORSFilter.java:80)
	at io.quarkus.vertx.http.runtime.cors.CORSFilter.handle(CORSFilter.java:17)
	at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1034)
	at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131)
	at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133)
	at io.quarkus.vertx.http.runtime.VertxHttpRecorder$14.handle(VertxHttpRecorder.java:1015)
	at io.quarkus.vertx.http.runtime.VertxHttpRecorder$14.handle(VertxHttpRecorder.java:986)
	at io.quarkus.vertx.http.runtime.VertxHttpRecorder$3.handle(VertxHttpRecorder.java:259)
	at io.quarkus.vertx.http.runtime.VertxHttpRecorder$3.handle(VertxHttpRecorder.java:255)
	at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1034)
	at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131)
	at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133)
	at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$2.handle(VertxHttpHotReplacementSetup.java:74)
	at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$2.handle(VertxHttpHotReplacementSetup.java:63)
	at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:327)
	at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366)
	at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:834)

maybe this is related to #9974

@hosseinmp76 hosseinmp76 added the kind/bug Something isn't working label Jul 9, 2020
@quarkusbot
Copy link

/cc @quarkusio/devtools

@aloubyansky
Copy link
Member

Should be fixed with #10459

@aloubyansky aloubyansky added this to the 1.7.0 - master milestone Jul 24, 2020
@gsmet gsmet modified the milestone: 1.7.0 - master Jul 28, 2020
@hosseinmp76
Copy link
Author

hosseinmp76 commented Aug 13, 2020

I updated my project to 1.7.0 and I still have this problem. now in the BootstrapAppModelFactory class in createBootstrapMavenContext method in line 211 projectPom is null and in line 216 the BootstrapMavenContext constructor returns null.
@aloubyansky should I open a new issue or one of collaborators would re-open this one?

@aloubyansky aloubyansky reopened this Aug 17, 2020
@aloubyansky aloubyansky removed this from the 1.7.0.CR1 milestone Aug 17, 2020
@aloubyansky
Copy link
Member

@glefloch will you have time to look into this one?

@glefloch
Copy link
Member

@aloubyansky yes I will

@glefloch glefloch self-assigned this Aug 17, 2020
@glefloch
Copy link
Member

@hosseinmp76, could you upload a reproducer ?

@hosseinmp76
Copy link
Author

hosseinmp76 commented Aug 18, 2020

@glefloch I tried to make a minimal reproducer so I made a new project but I got #11310 (with gradle 6.5)
but my real project is here. the main method is in
edu.sharif.surveyBackend.cli.Main

@glefloch
Copy link
Member

Thanks @hosseinmp76. I'm on the #11310 right now. Once I have a fix. I will try the fix on your project.

@glefloch
Copy link
Member

@hosseinmp76, I have a working fix for #11310. I cloned your project and I was able to reproduce your error.

Replacing your Main class with something like below fix the error:

@QuarkusMain
public class Main {

    public static void main(String[] args) {
        Quarkus.run(args);
    }
}

@hosseinmp76
Copy link
Author

@glefloch thank you. it works for me.
BTW is it my mistake in extending QuarkusApplication or is it a bug?

@gastaldi
Copy link
Contributor

Implementing QuarkusApplication requires you to override the run method, not a PSVM method. It's documented here: https://quarkus.io/guides/command-mode-reference

Closing this issue now. Thank you!

@gastaldi gastaldi added triage/invalid This doesn't seem right and removed kind/bug Something isn't working labels Aug 23, 2020
@hosseinmp76
Copy link
Author

Implementing QuarkusApplication requires you to override the run method, not a PSVM method. It's documented here: https://quarkus.io/guides/command-mode-reference

Closing this issue now. Thank you!

But the doc says:

If a class that implements QuarkusApplication and has a Java main then the Java main will be run.

so I can't see any problem with having PSVM and extending the class. maybe doc should be changed.

@gastaldi
Copy link
Contributor

Hm, you're right. I'll have a deeper look but if that's the case the docs should definitely be changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gradle Gradle triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

6 participants