joular / joularjx

JoularJX is a Java-based agent for software power monitoring at the source code level.
https://www.noureddine.org/research/joular/joularjx
GNU General Public License v3.0
71 stars 17 forks source link

Agent 1.5 no longer works on Wildfly Application Server #5

Closed adelnoureddine closed 2 months ago

adelnoureddine commented 1 year ago

(Issue initially posted by Robin Schimpf on our old gitlab repo).

I finally had time to test the new agent version on our main application which runs on the wildfly application server. But as soon as I attach the agent wildfly will fail to start with the following error. I already have set the -Djava.util.logging.manager=org.jboss.logmanager.LogManager as suggested in various places.

java.lang.RuntimeException: WFLYCTL0079: Failed initializing module org.jboss.as.logging
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.extension.ParallelExtensionAddHandler$1.execute(ParallelExtensionAddHandler.java:115)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:1045)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:777)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:466)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1427)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:522)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:554)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:516)
    at org.jboss.as.server@18.0.4.Final//org.jboss.as.server.ServerService.boot(ServerService.java:461)
    at org.jboss.as.server@18.0.4.Final//org.jboss.as.server.ServerService.boot(ServerService.java:414)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:455)
    at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: WFLYLOG0078: The logging subsystem requires the log manager to be org.jboss.logmanager.LogManager. The subsystem has not be initialized and cannot be used. To use JBoss Log Manager you must add the system property "java.util.logging.manager" and set it to "org.jboss.logmanager.LogManager"
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.extension.ParallelExtensionAddHandler$1.execute(ParallelExtensionAddHandler.java:107)
    ... 11 more
Caused by: java.lang.IllegalStateException: WFLYLOG0078: The logging subsystem requires the log manager to be org.jboss.logmanager.LogManager. The subsystem has not be initialized and cannot be used. To use JBoss Log Manager you must add the system property "java.util.logging.manager" and set it to "org.jboss.logmanager.LogManager"
    at org.jboss.as.logging@18.0.4.Final//org.jboss.as.logging.LoggingExtension.initialize(LoggingExtension.java:184)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.extension.ExtensionAddHandler.initializeExtension(ExtensionAddHandler.java:131)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.extension.ExtensionAddHandler.initializeExtension(ExtensionAddHandler.java:103)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.extension.ParallelExtensionAddHandler$ExtensionInitializeTask.call(ParallelExtensionAddHandler.java:144)
    at org.jboss.as.controller@18.0.4.Final//org.jboss.as.controller.extension.ParallelExtensionAddHandler$ExtensionInitializeTask.call(ParallelExtensionAddHandler.java:127)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
    at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
    at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
    at java.base/java.lang.Thread.run(Thread.java:829)
    at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)

I know that the elastic-apm agent had the same problem in https://github.com/elastic/apm-agent-java/issues/99 and they implemented something for that.

adelnoureddine commented 1 year ago

This seems related to Java logger and Java agents, not per se for JoularJX. I'll see what elastic did for their agent, and I can understand what's been changed, we'll how to integrate it here. Otherwise, we can detect if we're on Wildfly and disable logging accordingly.

adelnoureddine commented 1 year ago

@theobisproject Do you still have issues with version 2.0 of JoularJX?

theobisproject commented 1 year ago

@adelnoureddine Thanks for pinging. Got sidetracked by other stuff and haven't followed the project quite closely 😉 I did a quick test with the 2.0 agent and the issue is still the same as in 1.5

adelnoureddine commented 9 months ago

Without further info, and as it's related to logging, I'm closing this issue for now.

theobisproject commented 9 months ago

@adelnoureddine What further information would you need? I tested the agent again in the latest version and even with the OFF level the problem is still there.

As far as I understand the problem it comes from the agent initializing the logging library before Wildfly can initialize the library itself. So either deferring the initialization or completely removing logging when running within Wildfly would fix the problem. The agent runs correctly when i remove all logging and run my custom version.

adelnoureddine commented 9 months ago

Thanks for the precision. It's good to know that the issue is confirmed to be only related to logging rather than JoularJX directly. I'll see how to delay logging or detect the specific server and disable logging for it.

adelnoureddine commented 9 months ago

Red Hat has a detailed description of the error and proposed solutions here.