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 @ApplicationScoped working in dev run, but not in prod #23282

Closed
davidgomesdev opened this issue Jan 29, 2022 · 7 comments · Fixed by #23467
Closed

Quarkus @ApplicationScoped working in dev run, but not in prod #23282

davidgomesdev opened this issue Jan 29, 2022 · 7 comments · Fixed by #23467
Labels
area/kotlin env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@davidgomesdev
Copy link

Describe the bug

I have an abstract class, which has an implementation with @ApplicationScoped.

This works without an issue in quarkusDev, but when running the built app, it complains of a function that I have implemented in the abstract class.

java.lang.VerifyError: class me.l3n.[...].GoodReadsCrawlerService_ClientProxy overrides final method me.l3n.bot.[...].CrawlerService .parseHtml(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;

abstract class CrawlerService {
    protected suspend infix fun parseHtml(url: String): Document {
        /* ... */
    }
}

@ApplicationScoped
class GoodReadsCrawlerService: CrawlerService() {
    /* implements other abstract functions of base class */
}

Note that I'm not even overriding that parseHtml() function.

But if I change the GoodReadsCrawlerService to Singleton(), OR add the open keyword to parseHtml(), it works just fine in any case.

I'd assume the ClientProxy is treating the abstract class as an interface, so implements all functions for proxying, assuming they're all abstract.

But I believe this could be an issue with the prod proxy.

Expected behavior

The proxy should have the same behavior in dev and prod environments when dealing with an abstract class implementing a method.

Actual behavior

java.lang.VerifyError: class me.l3n.[...].GoodReadsCrawlerService_ClientProxy overrides final method me.l3n.bot.[...].CrawlerService .parseHtml(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;

Unless that method has the open keyword or the scope is changed to Singleton.

How to Reproduce?

In Kotlin, create an abstract class with a method implementation, then extend it from another class, with the @ApplicationScoped annotation.

Test in quarkusDev, then running the app produced in quarkusBuild.

An example can be found in my repo.

Output of uname -a or ver

Windows 10

Output of java -version

java version "11.0.12" 2021-07-20 LTS

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.1.Final

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

Gradle 7.2

Additional information

No response

@davidgomesdev davidgomesdev added the kind/bug Something isn't working label Jan 29, 2022
@quarkus-bot quarkus-bot bot added area/kotlin env/windows Impacts Windows machines labels Jan 29, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 29, 2022

/cc @evanchooly

@stuartwdouglas
Copy link
Member

@mkouba Could this be because of the additional interceptors that are applied in dev mode?

@mkouba
Copy link
Contributor

mkouba commented Jan 31, 2022

@mkouba Could this be because of the additional interceptors that are applied in dev mode?

I don't think so.

But if I change the GoodReadsCrawlerService to Singleton(),

@Singleton works because we don't ceate a client proxy at all.

OR add the open keyword to parseHtml(), it works just fine in any case.

So from CDI POV a normal scoped bean may not declare final methods (a type with a final method is not proxyable). In Quarkus, we try to relax this requirement and remove the final modifier if needed (and if quarkus.arc.transform-unproxyable-classes=true).

@stuartwdouglas Could it be that quarkus transformations are not taken into account when used together with kotlin?

@geoand
Copy link
Contributor

geoand commented Jan 31, 2022

Does the application work if quarkus.arc.dev-mode.monitoring-enabled=false is set?

@davidgomesdev
Copy link
Author

Does the application work if quarkus.arc.dev-mode.monitoring-enabled=false is set?

It doesn't. (neither in dev nor prod modes)

@stuartwdouglas
Copy link
Member

Do you have a reproducer that does not require a discord account?

@davidgomesdev
Copy link
Author

Just created one here.

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Feb 7, 2022
@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Feb 7, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.1.Final Feb 7, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kotlin env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants