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

Resteasy Reactive wants to instantiate abstract ContainerRequestFilter's in dev mode #16359

Closed
Postremus opened this issue Apr 8, 2021 · 4 comments · Fixed by #16360
Closed
Labels
area/devmode area/rest env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@Postremus
Copy link
Member

Describe the bug

First of all, I tried to create a reproducer, but was unable to reproduce this issue in an isolated project.

This only happens in dev mode. The app works when starting as fast-jar.

I debugged the problem a bit, and found out that the InstantiationException is thrown because an abstract class was tried to instantied - AbstractAuthenticationFilter.

See the stacktrace, and the screenshot from my debugger below.

This class comes from one of my common modules. It is defined like this:

public abstract class AbstractAuthenticationFilter<P extends TokenPrincipal> implements ContainerRequestFilter {

    // package private for unit tests
    @Context
    ResourceInfo resourceInfo;

    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {
    }
}

It is implemented like this:

@Provider
@Priority(2000)
@Consumes("*")
@Produces("*")
public class AuthenticationFilter extends AbstractAuthenticationFilter<AuthenticationTokenPrincipal> {
}

This works without a problem in Resteasy Classic, but fails in Resteasy Reactive.

Expected behavior

The application should start in dev mode, even when definining abstract ContainerRequestFilter.

Actual behavior

The application does not start in dev mode, and only prints the following log.

Listening for transport dt_socket at address: 5005
2021-04-08 11:52:58,839 INFO  [org.hib.val.int.uti.Version] (Quarkus Main Thread) HV000001: Hibernate Validator 6.2.0.Final
2021-04-08 11:52:59,042 INFO  [org.hib.jpa.int.uti.LogHelper] (Quarkus Main Thread) HHH000204: Processing PersistenceUnitInfo [name: <default>]
2021-04-08 11:52:59,065 INFO  [org.hib.Version] (Quarkus Main Thread) HHH000412: Hibernate ORM core version 5.4.29.Final
2021-04-08 11:52:59,080 INFO  [org.hib.ann.com.Version] (Quarkus Main Thread) HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-04-08 11:52:59,125 INFO  [org.hib.dia.Dialect] (Quarkus Main Thread) HHH000400: Using dialect: io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL10Dialect
2021-04-08 11:52:59,315 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure
2021-04-08 11:52:59,318 ERROR [io.qua.run.boo.StartupActionImpl] (Quarkus Main Thread) Error running Quarkus: 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.runner.bootstrap.StartupActionImpl$3.run(StartupActionImpl.java:134)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ExceptionInInitializerError
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at java.base/java.lang.Class.newInstance(Class.java:584)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:65)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
        at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
        ... 6 more
Caused by: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:392)
        ... 15 more
Caused by: java.lang.RuntimeException: java.lang.InstantiationException
        at io.quarkus.arc.runtime.BeanContainerImpl$DefaultInstanceFactory.create(BeanContainerImpl.java:75)
        at io.quarkus.resteasy.reactive.common.runtime.ArcBeanFactory.createInstance(ArcBeanFactory.java:25)
        at org.jboss.resteasy.reactive.server.core.startup.RuntimeInterceptorDeployment.createInterceptorInstances(RuntimeInterceptorDeployment.java:152)
        at org.jboss.resteasy.reactive.server.core.startup.RuntimeInterceptorDeployment.<init>(RuntimeInterceptorDeployment.java:62)
        at org.jboss.resteasy.reactive.server.core.startup.RuntimeDeploymentManager.deploy(RuntimeDeploymentManager.java:90)
        at io.quarkus.resteasy.reactive.server.runtime.ResteasyReactiveRecorder.createDeployment(ResteasyReactiveRecorder.java:112)
        at io.quarkus.deployment.steps.ResteasyReactiveProcessor$setupEndpoints1722748754.deploy_3(ResteasyReactiveProcessor$setupEndpoints1722748754.zig:12440)
        at io.quarkus.deployment.steps.ResteasyReactiveProcessor$setupEndpoints1722748754.deploy(ResteasyReactiveProcessor$setupEndpoints1722748754.zig:55)
        at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:361)
        ... 15 more
Caused by: java.lang.InstantiationException
        at java.base/jdk.internal.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at java.base/java.lang.Class.newInstance(Class.java:584)
        at io.quarkus.arc.runtime.BeanContainerImpl$DefaultInstanceFactory.create(BeanContainerImpl.java:67)
        ... 23 more

To Reproduce

Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific).

Or attach an archive containing the reproducer to the issue.

Steps to reproduce the behavior:
1.
2.
3.

Configuration

# Add your application.properties here, if applicable.

Screenshots

image

Environment (please complete the following information):

Output of uname -a or ver

MSYS_NT-10.0 NANB7NLNVP2 2.10.0(0.325/5/3) 2018-06-13 23:34 x86_64 Msys

Output of java -version

java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)

Quarkus version or git rev

1.13.1.Final

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

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\eclipse\tools\apache-maven\bin..
Java version: 11.0.7, vendor: Azul Systems, Inc., runtime: C:\eclipse\tools\zulu11.39.15-ca-jdk11.0.7-win_x64
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

@Postremus Postremus added the kind/bug Something isn't working label Apr 8, 2021
@quarkus-bot quarkus-bot bot added area/devmode area/rest env/windows Impacts Windows machines labels Apr 8, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 8, 2021

/cc @FroMage, @geoand, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Apr 8, 2021

Can you try and give #16360 a shot @Postremus ?

@Postremus
Copy link
Member Author

@geoand The app now starts in dev mode with your PR. Thank you!

Listening for transport dt_socket at address: 5005
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2021-04-08 17:14:32,151 INFO  [io.quarkus] (Quarkus Main Thread) rr-abstract-base-filter 1.0.0-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 3.842s. Listening on: http://loc
alhost:8080
2021-04-08 17:14:32,152 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2021-04-08 17:14:32,152 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, config-yaml, hibernate-validator, mutiny, resteasy-reactive, resteasy-reactive-jackson, smallrye-
context-propagation]

@geoand
Copy link
Contributor

geoand commented Apr 8, 2021

Awesome, thanks for checking @Postremus

geoand added a commit that referenced this issue Apr 8, 2021
Ignore abstract classes in Filter hierarchy
@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone Apr 8, 2021
@gsmet gsmet modified the milestones: 2.0 - main, 1.13.2.Final Apr 10, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devmode area/rest env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants