Hello everybody,

We're hitting a small issue in Camel that unfortunately causes Hawtio to
crash after upgrading to Camel 4 (and Hawtio 4).

Hawtio crashes due to a duplicate MBean operation being exposed when using
a json-validator endpoint (and possibly some other endpoints as well). I
made a small project with a json-validator endpoint to reproduce the issue.
The project is available here:
https://github.com/rphgoossens/json-validation
When you start it up and try to open the Hawtio dashboard (
http://localhost:8080/actuator/hawtio), you'll notice it won't display
anything and there's an error visible in the web console.

The underlying issue (after some digging) appears to be a duplicate MBean
Operation being exposed for the json-validator endpoint
(clearContentCache())

[image: Screenshot 2024-05-31 at 09.58.41.jpg]

The duplication is a result of a ManagedOperation annotation being present
on the clearContentCache method of the ResourceEndpoint class (a superclass
of the JsonValdatorEndpoint class) and a ManagedOperation annotation being
present on the clearContentCache method of the ManagedResourceEndpointMBean
interface (an interface that the JsonValidatorEndpoint class implements).
When you hover over both buttons in VisualVm (picture above), you'll both
buttons having different descriptions (one has the description of the
annotation in the ResourceEndpoint class and the other gets its description
from the ManagedResourceEndpointMBean interface)

[image: Screenshot 2024-05-31 at 10.03.26.jpg]
[image: Screenshot 2024-05-31 at 10.03.49.jpg]

Funny thing is that the duplication of the operation will NOT take place if
the descriptions in the ManagedOperation annotations are the same (which
they currently are not obviously). I tested this by shadowing the
ResourceEndpoint class in my project and adjusting the description.
ManagedAttribute annotations that are duplicated in ResourceEndpoint and
ManagedResourceEndpointMBean (like isContentCache()) with different
descriptions are not duplicated in the MBean exposure funny enough.

You can argue that this shouldn't cause a crash in Hawtio (and it didn't in
the 3 version), but the duplicate MBean operation is a small bug IMHO,
since both operations in the end will call the same method. Only the one
coming from the class at the bottom of the hierarchy (in this case
the ResourceEndpoint one) should be exposed.

So my request would be to create a Camel issue to solve this in a future
Camel version.

The only workaround we currently have is to set the
camel.main.jms-management-m-beans-level to contextonly. Then Hawtio will
load without errors, but then we're missing a lot MBean functionality, eg.
stop and start individual routes in the project.

I hope the information I provided was helpful and complete. Feel free to
mail me for any additional questions and please let me know if you will
create an issue for this.

Best Regards,
Roger Goossens.

Reply via email to