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
How to implement compatibility of the Jolokia JVM agent with org.jboss.logmanager.LogManager loaded form JBoss modules #258
Comments
@rraez thanks for coming back to this (annoying ;-) issue. Lets fix it now :) To your additional suggestions:
I guess this would mean to include an extra dependency (asm, another http-server) which I'm not keen on. Jolokia was designed with the constraint to be as small as possible in order to minimize impact. The only dependency is on json-simple (23k), not even logging. You suggestion around option (2) sounds feasible. Do you think there could be a way to detect early and quickly whether running in an Wildfly environment so that we could set the suggested option The reason I ask is because its really only the Wildfly platform which has this issue, not one of the other 30+ platform in my integration test suite (including the former JBoss AS servers) has a similar problem. I had different issues on different platform (e.g. for detecting the MBeanServer on Weblogic is also not trivial), so use server detection like the JBossServerDetector to cope with platform peculiarities. It would be cool if we could include our workaround into this facility, too, but I'm afraid the detector stuff kicks in too late. To sacrifice an option (of which I already have too many I'm afraid) should be the last resort. Said that I would happily integrate a PR or even the vanilla detection code if you have POC. Thanks again for you investigating this tricky thing. |
Thanks for you quick response. I definitely agree to keep the dependencies as minimal as possible, this is a key strength of Jolokia. I like your idea, I will think about the automatic detection of JBoss module based JEE platforms (Wildfily, JBoss EAP 6+). This detection must not kick off just in case some JBoss libraries are on the class path. JBoss modules is used not only for the appserver, e.g. it is used to implement modules in the ceylon language. |
… and fixed a startup issue caused by a JBoss modules based server triggered by a custom java LogManager. For details an discussion see rhuss#258.
Finally I'm about to integrate this fix into Jolokia (although I think swarm would be the more appropriate place). The final missing piece is how to detect whether running und wildfly-swarm, which must be available early on.
The current algorithm checks two things:
It would be awesome if someone could either verify that this is necessary and sufficient, or if otherwise please update this issue with a unique way to identify swarm. Also it would be awesome if Swarm could be detected to extract its version number so that Jolokia can expose this to the outside (and while we are here also, how to differentiate between Wildfly AS and wildfly-swarm since this detector is used for both platforms) |
I've successfully tested swarm with jolokia 1.3.6-SNAPSHOT: https://issues.jboss.org/browse/SWARM-204 |
We have migrated several (slightly complex) EE applications to Swarm and have seen that the Swarm detection of Jolokia in agent mode is likely sensitive to timing issues. In ca. 20% of application restarts the detection fails, and we get the same exception as in the original description. I tried to reproduce it with a toy application, but was able to do so up too now. |
I probably need some assistance to find the proper variables which are available right from the start, as mentioned in #258 (comment) @rwiermer Maybe we should open an issue at wildfly swarm for that ? |
Problem
Currently we have enabled the Jolokia JVM agent with JBoss EAP 6.0.x & 6.2.x.
To get the JVM Agent running, we have added the
jboss-logmanager.jar
the the-Xbootclasspath
.This is currently the official workaround described by RedHat: https://access.redhat.com/solutions/312453
Alos other JVM agents have the same problem: https://issues.jboss.org/browse/WFLY-895
But in JBoss EAP 6.4. this is no more working:
Even when you add the system property
java.util.logging.manager=org.jboss.logmanager.LogManager
and add thejboss-logmanager.jar
the the -Xbootclasspath, the following code throws a class cast exception:https://github.com/jboss-logging/jboss-logmanager/blob/master/src/main/java/org/jboss/logmanager/Logger.java#L57
This exception is caused by changed class loading behaviour in JBoss eap 6.4. It looks like the
org.jboss.logmanager.Logger
class is loaded a second time from the modules and therefore it can't be casted.In my option it was never a clean solution to override classes loaded by JBoss modules via the system class loader (
-Xbootclasspath
).I have to find a solution for already released version of JBoss eap (6.2.2, 6.4.1, 6.4.7).
Implement a solution for the problem in products is not easy
I agree with you suggestion that a solution within the product (e.g. swarm ) would be nice, but it is not that simple, as the
java.util.logging.LogManager
of java is a singleton initialized the first time it is used.Target
The Jolokia JVM agent should be running fine in environments where the
java.util.logging.LogManager
is initialized by the application at runtime with a class which is loaded from a custom class loader.Possible options
You have already thought how to solve this in a clean and portable approach: https://issues.jboss.org/browse/SWARM-204
Option 1 is not solving the issue as the issue in EAP 6.4 is triggered by the too early loading.
Option 2 I definitely like the option 2, more on this later
Option 3 this option would cause a race condition: in case jolokia is called before JBoss has initialized the, we have the same problem agin
Option 4 this could be an option, but it would not be bulled prove: java running on virtual server have no kind of guarantees
I have some additional options:
java.util.Logger
.Option 5 has a small runtime impact, and is most likely too confusing/magic for maintainers & users.
Option 6 would be an option, I have no idea which implementation to take, its size should be small and I don't would like to follow this as it is too much work and requires extensive testing.
IMO a solution of option 2 is the way to go.
Proposal for option 2
Here a proposal to implement option 2:
awaitJavaUtilLoggingManagerConfiguration
java.util.logging.manager
is setjava.util.logging.manager
is loaded by the JVM and remember its class loaderLogManager.getLogManager()
and log a warning in case the result is not the expected classTo check if a class has been loaded, I propose to poll Instrumentation.getAllLoadedClasses
The steps 3-6 are needed for the case in which JBoss (or any other component) has configured the system property an loaded the class but the LogManager is not jet initialized.
In the case of JBoss, the steps 3-6 are required if:
org.jboss.logmanager.LogManager
To get an instance of Instrumentation, the JVM agent needs to be implemented with the following signature:
public static void premain(String args, Instrumentation inst)
I think the solution should not introduce time outs as this will complicate the implementation. I think logging the most important steps should be enough.
What do you think about this proposal for the option 2?
The text was updated successfully, but these errors were encountered: