Skip to content

Conversation

@Vin-it-9
Copy link

Summary

This PR improves the MongoDB guides by fixing native-image compatibility issues and correcting outdated wording.

Changes included

1. Add @ReflectiveAccess to Fruit POJO

The MongoDB Java driver’s POJO codec uses reflection to access constructors and fields.
When building GraalVM native images, reflection metadata must be explicitly provided.

Adding @ReflectiveAccess ensures Micronaut’s Graal annotation processor generates the required reflection configuration automatically.

Files updated:

  • micronaut-mongodb-synchronous/java/Fruit.java
  • micronaut-mongodb-asynchronous/java/Fruit.java
  • micronaut-mongodb-synchronous/kotlin/Fruit.kt

2. Documentation improvements

  • Added a native-image note explaining why @ReflectiveAccess is required for MongoDB POJO codec.
  • Corrected “mongo-sync” → “mongo-reactive” in the asynchronous guide’s Test section.
  • Cleaned formatting around the POJO section so examples render properly.

Files updated:

  • micronaut-mongodb-synchronous.adoc
  • micronaut-mongodb-asynchronous.adoc

Why this is needed

Without reflection metadata, GraalVM native images fail with:

@CLAassistant
Copy link

CLAassistant commented Nov 29, 2025

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

2 participants