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

Jackson-databind reflection problem with swagger-ui #10220

Closed
mebigfatguy opened this issue Nov 20, 2024 · 5 comments
Closed

Jackson-databind reflection problem with swagger-ui #10220

mebigfatguy opened this issue Nov 20, 2024 · 5 comments

Comments

@mebigfatguy
Copy link

Using swagger-ui version 2.2.26 and jackson-databind version 2.18.1, on jdk21, i get tons of these errors..

ERROR io.swagger.v3.core.jackson.ModelResolver - Neither 'findJsonValueMethod' nor 'findJsonValueAccessor' found in jackson BeanDescription. Please verify your Jackson version.

When i look in jackson-databind, findJsonValueMethod has indeed been recently removed but i do see

/**
 * Method for locating accessor (readable field, or "getter" method)
 * that has
 * {@link com.fasterxml.jackson.annotation.JsonValue} annotation,
 * if any. If multiple ones are found,
 * an error is reported by throwing {@link IllegalArgumentException}
 *
 * @since 2.9
 */
public abstract AnnotatedMember findJsonValueAccessor();

So i was wondering if anyone could tell me what i am doing wrong here??
(it would also be nice to log beanDesc.getClass().getClassName() in that error message.)

@funfried
Copy link

I have the same issue, it seems it's related to having webflux and webmvc libraries inside the classpath (which is not good and I have to fix that in my case sometime), but what's strange is that the error message disappears when downgrading back to swagger 2.2.25 still having webflux and webmvc in my classpath.

@ftreede
Copy link

ftreede commented Nov 26, 2024

This is definetely a bug in swagger. Jackson removed the deprecated findJsonValueMethod method with 2.18: FasterXML/jackson-databind#4525

https://github.com/swagger-api/swagger-core/blob/df88c8a8ebaae1cb8ec39d1af295d07620dcaf87/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java#L1157-L1179

This code first tries the new method, finds it and invokes it. However, if that method returns null, the return is not called and it then tries the old method.

@ftreede
Copy link

ftreede commented Nov 26, 2024

This is actually an issue in swagger, core: check over there: swagger-api/swagger-core#4755

@Keshav2107
Copy link

I am still facing this issue. is there any solution for this ?

Ahoo-Wang added a commit to Ahoo-Wang/swagger-core that referenced this issue Dec 11, 2024
ndwlocatieservices added a commit to ndwnu/nls-accessibility-map that referenced this issue Dec 19, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [nu.ndw.nls.locationdataissuesapi:client-feign](https://dev.azure.com/ndwnu/NLS/_git/nls-location-data-issues) ([source](https://dev.azure.com/ndwnu/NLS/_git/nls-location-data-issues)) | compile | patch | `1.0.14` -> `1.0.15` |
| nu.ndw.nls.geojson.geometry:specification |  | patch | `1.3.5` -> `1.3.8` |
| nu.ndw.nls.geojson.geometry:specification-open-api-config |  | patch | `1.3.5` -> `1.3.8` |
| nu.ndw.nls.geojson.geometry:geometry-model | compile | patch | `1.3.5` -> `1.3.8` |
| nu.ndw.nls.geojson.geometry:specification | compile | patch | `1.3.5` -> `1.3.8` |
| nu.ndw.nls.geojson.geometry:geometry-jts | compile | patch | `1.3.5` -> `1.3.8` |
| [nu.ndw.nls:routing-map-matcher-library](https://github.com/ndwnu/nls-routing-map-matcher) | compile | minor | `13.2.4` -> `13.3.0` |
| [io.swagger.core.v3:swagger-annotations](https://github.com/swagger-api/swagger-core) | compile | patch | `2.2.26` -> `2.2.27` |

---

### Release Notes

<details>
<summary>swagger-api/swagger-core (io.swagger.core.v3:swagger-annotations)</summary>

### [`v2.2.27`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.27): Swagger-core 2.2.27 released!

[Compare Source](swagger-api/swagger-core@v2.2.26...v2.2.27)

-   fix: swagger-api/swagger-ui#10220 ([#&#8203;4806](swagger-api/swagger-core#4806))
-   Fix for record component annotations on fields with JsonProperty annotations ([#&#8203;4795](swagger-api/swagger-core#4795))
-   Fix java.lang.NullPointerException and remove stack trace output from ModelResolver ([#&#8203;4793](swagger-api/swagger-core#4793))
-   Move applySchemaResolution check to a method ([#&#8203;4791](swagger-api/swagger-core#4791))
-   feat(gradle-plugin): enable lazy evaluation, implicit task dependencies and fixing `setEncoding` ([#&#8203;4761](swagger-api/swagger-core#4761))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or PR is renamed to start with "rebase!".

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
@codesimplicity
Copy link

As I came here when trying to get that running in GraalVM (Spring Native), I wanted to add some more details for others having the same issue:

  • the current handling assumes that the Exception is thrown because the method does not exist but in GraalVM I think it may be a different error - is it worth to create a PR to improve that error handling? (haven't checked the exact exception thrown)
  • I had to add this to RuntimeHints in my Spring Boot app to remove the error:
            .registerType(
                BeanDescription::class.java,
                MemberCategory.INVOKE_DECLARED_METHODS,
            )
  • I have also added some more RuntimeHints until it worked:
            .registerType(MethodHandles.Lookup::class.java)
            .registerType(
                Schema31Mixin.TypeSerializer::class.java,
                MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
            )
            .registerType(
                JsonSchema::class.java,
                MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
            )

The metadata repositories will hopefully include those details soon but until then...

axeloradmin pushed a commit to axelor/axelor-open-platform that referenced this issue Jan 30, 2025
This fix API Swagger documentation error due to jackson version
mismatch. See swagger-api/swagger-ui#10220.

Fixes #1347
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants