how a -javaagent can use logging and not blow up WildFly

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

how a -javaagent can use logging and not blow up WildFly

John Mazzitelli
Regarding this issue:

    https://bugzilla.redhat.com/show_bug.cgi?id=1037970

and the exception message:

    JBAS011592: 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"

How would one go about working around this when you have a -javaagent deployed in WildFly/EAP and that agent code actually uses logging?

I've tried a bunch of stuff such as setting the sysprop java.util.logging.manager=org.jboss.logmanager.LogManager (both in standalone.conf and passing in via standalone.sh); in the agent code, first thing is call System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager"); I've tried getting the agent code to sleep and not even do any work until WildFly starts booting (though I'm not sure if some of my classes are getting loaded at the time premain() is called, but I can't see where its importing any logging stuff - unless its happening in low-level Java API code and setting java.util.logging itself?)

There has to be a way to do this - I'm thinking of things like byteman which probably ran into the same thing. I'm hoping there is a simple "oh, you just do this magical step and it works around the problem."

_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: how a -javaagent can use logging and not blow up WildFly

Tomaž Cerar-2

On Sat, Mar 4, 2017 at 11:42 PM, John Mazzitelli <[hidden email]> wrote:
"oh, you just do this magical step and it works around the problem."

With recent builds setting system property org.wildfly.logging.skipLogManagerCheck=true
should workaround your problem.


--
tomaz

_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: how a -javaagent can use logging and not blow up WildFly

John Mazzitelli
> > "oh, you just do this magical step and it works around the problem."
>
> With recent builds setting system property org.wildfly.logging.skipLogManagerCheck=true
> should workaround your problem.

Ah.. That's a good one to know.

I need something for earlier WildFly and EAP builds, though. But I recently found this solves my problem (this worked for me on both EAP6 and EAP7.1):

Inside standalone.conf:

# Add "org.jboss.logmanager" to the JBoss Modules system packages
if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
   JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman,org.jboss.logmanager"
fi

#   Explicitly tell the VM to use the JBoss Log Manager via -Djava.util.logging.manager system property.
#   Use the -javaagent VM option to load the agent
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager -javaagent:my-agent.jar"

That seems to fix my problem.
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: how a -javaagent can use logging and not blow up WildFly

Emmanuel Hugonnet
Yes this works.
This is how the NetBeans Profiler works around that :)

Le 05/03/2017 à 23:18, John Mazzitelli a écrit :

>>> "oh, you just do this magical step and it works around the problem."
>>
>> With recent builds setting system property org.wildfly.logging.skipLogManagerCheck=true
>> should workaround your problem.
>
> Ah.. That's a good one to know.
>
> I need something for earlier WildFly and EAP builds, though. But I recently found this solves my problem (this worked for me on both EAP6 and EAP7.1):
>
> Inside standalone.conf:
>
> # Add "org.jboss.logmanager" to the JBoss Modules system packages
> if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
>    JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman,org.jboss.logmanager"
> fi
>
> #   Explicitly tell the VM to use the JBoss Log Manager via -Djava.util.logging.manager system property.
> #   Use the -javaagent VM option to load the agent
> JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager -javaagent:my-agent.jar"
>
> That seems to fix my problem.
> _______________________________________________
> wildfly-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>

_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev

signature.asc (484 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: how a -javaagent can use logging and not blow up WildFly

James Perkins
In reply to this post by John Mazzitelli


On Sun, Mar 5, 2017 at 2:18 PM, John Mazzitelli <[hidden email]> wrote:
> > "oh, you just do this magical step and it works around the problem."
>
> With recent builds setting system property org.wildfly.logging.skipLogManagerCheck=true
> should workaround your problem.

Ah.. That's a good one to know.

I need something for earlier WildFly and EAP builds, though. But I recently found this solves my problem (this worked for me on both EAP6 and EAP7.1):

Inside standalone.conf:

# Add "org.jboss.logmanager" to the JBoss Modules system packages
if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
   JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman,org.jboss.logmanager"
fi

#   Explicitly tell the VM to use the JBoss Log Manager via -Djava.util.logging.manager system property.
#   Use the -javaagent VM option to load the agent
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager -javaagent:my-agent.jar"

This is the correct solution. Skipping the check could potentially be an issue if the log manager installed is not the jboss-logmanager. Adding system module (or adding the library to the boot class path) and the java.util.logging.manager as the first system property in the JAVA_OPTS is the correct way to handle this.
 

That seems to fix my problem.
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev



--
James R. Perkins
JBoss by Red Hat

_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev