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

Fix integration with Micronaut Control Panel #715

Merged
merged 2 commits into from
Sep 17, 2024
Merged

Fix integration with Micronaut Control Panel #715

merged 2 commits into from
Sep 17, 2024

Conversation

melix
Copy link
Collaborator

@melix melix commented Sep 17, 2024

This commit provides a fix for the control panel not being loaded when using Micronaut 4.6. It turns out that this highlighted a deeper issue with classloading in test resources. In particular, there are a couple of problems:

  1. the server module uses Micronaut AOT to optimize the binary. However, once the server is optimized, this prevents additional beans to be registered when using Micronaut 4.6+. Since the control panel module is an additional module, this wasn't loaded anymore, which is the root issue of this bug.
  2. however, once the service loading optimization is disabled, another hidden issue surfaced: because the server uses a shaded jar in order to be able to use the Micronaut BOM independently in user applications, once the control panel module is added, we ended up with duplicate Micronaut classes on classpath.

Fixing 2 isn't trivial, since we need a single dependency graph on the server side. In order to avoid breaking changes, and to make sure that the solution works both for Maven and Gradle, this commit introduces a new utility in the TestResourcesClasspath class from the build-tools module, so that the Maven and Gradle plugins can filter out dependencies which are already packaged into the jar (e.g Micronaut Core, Micronaut Context, ...).
This fixes the loading of the control panel module, in a backwards compatible way. In addition, it should fix the issue for user-written custom modules too. However, this will not prevent modules which are written for an
incompatible version of Micronaut to break when loaded in the server.

Fixes #705

Important : the complete fix will require changes in both the Gradle and Maven plugins to use that new method for filtering the classpath.

This commit provides a fix for the control panel not being loaded
when using Micronaut 4.6. It turns out that this highlighted a
deeper issue with classloading in test resources. In particular,
there are a couple of problems:

1. the server module uses Micronaut AOT to optimize the binary.
However, once the server is optimized, this prevents additional
beans to be registered when using Micronaut 4.6+. Since the
control panel module is an additional module, this wasn't loaded
anymore, which is the root issue of this bug.
2. however, once the service loading optimization is disabled,
another hidden issue surfaced: because the server uses a shaded
jar in order to be able to use the Micronaut BOM independently
in user applications, once the control panel module is added,
we ended up with duplicate Micronaut classes on classpath.

Fixing 2 isn't trivial, since we need a single dependency
graph on the server side. In order to avoid breaking changes,
and to make sure that the solution works both for Maven and
Gradle, this commit introduces a new utility in the
`TestResourcesClasspath` class from the `build-tools` module,
so that the Maven and Gradle plugins can filter out
dependencies which are already packaged into the jar (e.g
Micronaut Core, Micronaut Context, ...).
This fixes the loading of the control panel module, in a
backwards compatible way. In addition, it should fix the
issue for user-written custom modules too. However, this
will not prevent modules which are written for an
incompatible version of Micronaut to break when loaded in
the server.

Fixes #705
@melix melix added the type: bug Something isn't working label Sep 17, 2024
@melix melix added this to the 2.6.1 milestone Sep 17, 2024
Copy link

sonarcloud bot commented Sep 17, 2024

@melix melix merged commit dcedbab into 2.6.x Sep 17, 2024
11 checks passed
@melix melix deleted the cc/issue-705 branch September 17, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Control Panel is broken with Micronaut 4.6+
2 participants