quarkusio / quarkus

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

kogito conflicts with resteasy reactive #19868

Closed vsevel closed 2 years ago

vsevel commented 3 years ago

Describe the bug

Adding the kogito-quarkus and quarkus-resteasy-reactive leads to the following error:

[INFO] Running org.acme.GreetingResourceTest
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 10.362 s <<< FAILURE! - in org.acme.GreetingResourceTest
[ERROR] org.acme.GreetingResourceTest.testHelloEndpoint  Time elapsed: 0.009 s  <<< ERROR!
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Multiple matching properties for name "security.jaxrs.deny-unannotated-endpoints" property was matched by both public boolean io.quarkus.resteasy.reactive.common.runtime.JaxRsSecurityConfig.denyJaxRs and public boolean io.quarkus.resteasy.runtime.JaxRsSecurityConfig.denyJaxRs. This is likely because you have an incompatible combination of extensions that both define the same properties (e.g. including both reactive and blocking database extensions)
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Multiple matching properties for name "security.jaxrs.deny-unannotated-endpoints" property was matched by both public boolean io.quarkus.resteasy.reactive.common.runtime.JaxRsSecurityConfig.denyJaxRs and public boolean io.quarkus.resteasy.runtime.JaxRsSecurityConfig.denyJaxRs. This is likely because you have an incompatible combination of extensions that both define the same properties (e.g. including both reactive and blocking database extensions)
Caused by: java.lang.IllegalArgumentException: Multiple matching properties for name "security.jaxrs.deny-unannotated-endpoints" property was matched by both public boolean io.quarkus.resteasy.reactive.common.runtime.JaxRsSecurityConfig.denyJaxRs and public boolean io.quarkus.resteasy.runtime.JaxRsSecurityConfig.denyJaxRs. This is likely because you have an incompatible combination of extensions that both define the same properties (e.g. including both reactive and blocking database extensions)

This is caused by kogito depending on classic resteasy (non reactive).

Expected behavior

Should not conflict with one another.

Actual behavior

Fails at build time.

I have tried excluding resteasy from kogito:

    <dependency>
      <groupId>org.kie.kogito</groupId>
      <artifactId>kogito-quarkus</artifactId>
      <exclusions>
        <exclusion>
          <groupId>io.quarkus</groupId>
          <artifactId>quarkus-resteasy</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

but it leads to the following error:

[INFO] Running org.acme.GreetingResourceTest
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 9.921 s <<< FAILURE! - in org.acme.GreetingResourceTest
[ERROR] org.acme.GreetingResourceTest.testHelloEndpoint  Time elapsed: 0.008 s  <<< ERROR!
java.lang.RuntimeException: java.lang.NoClassDefFoundError: io/quarkus/resteasy/runtime/QuarkusRestPathTemplate
Caused by: java.lang.NoClassDefFoundError: io/quarkus/resteasy/runtime/QuarkusRestPathTemplate
Caused by: java.lang.ClassNotFoundException: io.quarkus.resteasy.runtime.QuarkusRestPathTemplate

How to Reproduce?

  1. Create the kogito-quickstart sample application
  2. Replace extension quarkus-resteasy with quarkus-resteasy-reactive
  3. Build

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.1

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

No response

Additional information

No response

quarkus-bot[bot] commented 3 years ago

/cc @FroMage, @evacchi, @geoand, @mariofusco, @stuartwdouglas

evacchi commented 3 years ago

I'd say that's kind of expected because internally we codegen targeting resteasy plain, hence the conflict. The good news is that it is possible to opt-out of code-gen and soon there will be a way to write your own REST endpoints

vsevel commented 3 years ago

for reference: https://blog.kie.org/2020/04/kogito-a-modular-codegen-design-proposal.html

when will this be available? and will it mean that we can exclude the resteasy transitive dependencies?

evacchi commented 3 years ago

it is already possible to opt-out of codegen https://blog.kie.org/2021/08/kogito-1-10-0-released.html however the dependency will be still brought in. I think we should be able to address that by detecting the presence of the resteasy extension [1]

however, if you opt-out at the moment in general you basically won't be able to write your own REST endpoints as there is currently no public API for that -- the good news is that we are working on it https://github.com/kiegroup/kogito-runtimes/pull/1546 and I believe we will start to roll that out in a few weeks

If you want to use rules, at the moment there is already support for custom REST endpoint through the "legacy" API https://github.com/kiegroup/kogito-examples/tree/stable/rules-legacy-quarkus-example

[1] I have created a JIRA to track this https://issues.redhat.com/browse/KOGITO-5817

geoand commented 3 years ago

With https://github.com/kiegroup/kogito-runtimes/pull/1546 in, what else needs to be done to address this?

vsevel commented 3 years ago

it is not clear to me. I see https://issues.redhat.com/browse/KOGITO-5817 is still unresolved. do we need this also @evacchi?

evacchi commented 3 years ago

the extension still depends on resteasy, I will see if it is possible to handle that ASAP

evacchi commented 3 years ago

I am looking into this. For one it looks like the OP is not excluding quarkus-resteasy-jackson. The PR makes both optional https://github.com/kiegroup/kogito-runtimes/pull/1643

evacchi commented 3 years ago

status update: the PR above addresses the issue by allowing users to opt-out of codegen. Codegen is activated when either resteasy or resteasy-reactive are available. However it looks like resteasy is not exporting the endpoints correctly, because they return errors. They are correctly generated and they show up in Swagger UI.

I'll open an issue

EDIT: https://github.com/quarkusio/quarkus/issues/20846

geoand commented 2 years ago

I think we can close this now as there have been multiple fixes in Quarkus and the upcoming Kogito version