Question

I created a java application and initialize a java.util.Logger with that application and run that application as -javaagent with jboss AS 7 server and i got IllegalStateException (i am using eclipse IDE).Here follows my logger initialization code


static public void setup() throws IOException {

        // Get the global logger to configure it
        Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);

        logger.setLevel(Level.INFO);
        fileTxt = new FileHandler("C:/Users/abc/Desktop/ATAGENT/Logging.txt");
        fileHTML = new FileHandler("C:/Users/abc/Desktop/ATAGENT/Logging.html");

        // create txt Formatter
        formatterTxt = new SimpleFormatter();
        fileTxt.setFormatter(formatterTxt);
        logger.addHandler(fileTxt);

        // create HTML Formatter
        formatterHTML = new BMITHtmlFormatter();
        fileHTML.setFormatter(formatterHTML);
        logger.addHandler(fileHTML);
      }

When i create -javaagent jar appended with above lines of code and run with jboss as7 server i got following exception


WARNING: Failed to load the specified log manager class org.jboss.logmanager.LogManager
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.jboss.as.server.Main.main(Main.java:73)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.modules.Module.run(Module.java:260)
    at org.jboss.modules.Main.main(Main.java:291)
Caused by: java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager")
    at org.jboss.logmanager.Logger.getLogger(Logger.java:60)
    at org.jboss.logmanager.log4j.BridgeRepositorySelector.(BridgeRepositorySelector.java:42)
    ... 7 more

And i serched in fourms and i got a solution which is Open the launch configuration for the server definition. and add -logmodule org.jboss.logmanager to the program arguments before org.jboss.as.standalone. But it results the same exception with some additional warning. Here follows the exception


WARNING: -logmodule is deprecated. Please use the system property 'java.util.logging.manager' or the 'java.util.logging.LogManager' service loader.
WARNING: Failed to load the specified log manager class org.jboss.logmanager.LogManager
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.jboss.as.server.Main.main(Main.java:73)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.modules.Module.run(Module.java:260)
    at org.jboss.modules.Main.main(Main.java:291)
Caused by: java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager")
    at org.jboss.logmanager.Logger.getLogger(Logger.java:60)
    at org.jboss.logmanager.log4j.BridgeRepositorySelector.(BridgeRepositorySelector.java:42)
    ... 7 more

Was it helpful?

Solution

I had the same problem with JBOSS EAP 6, it took me 2 days for find a solution !.

The cause is that your agent need to create a Logger at statup, he need to be able to access the logmanager classes before JBOSS Modules has been initialized. You need to add JBoss LogManager to the boot classloader. Then, there will be a conflict between LogManager available via ModuleClassLoader and classes loaded via system classloader.

The solution is to make Java Agent and JBoss Modules use the same classloader to load the LogManager classes.

For EAP 6, In your standalone.conf (or domain) (It must be close for your version)

add

JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/modules/org/jboss/logmanager/main/jboss-logmanager-1.3.1.jar"

and for make Java Agent and JBoss Modules use the same classloader

modify this piece of code in adding org.jboss.logmanager like this :

if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
    JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman,org.jboss.logmanager"
fi

Hope this will help.

OTHER TIPS

I found the solution after searching for couple of days in the below link. https://github.com/jbossas/jboss-as-maven-plugin/issues/40#issuecomment-14943429

I have to tweak a little bit to get is work in Windows 7.

  1. Open Eclipse.
  2. Add Jboss 7.1 Runtime 1 server.
  3. Select the Server and press F3.
  4. Click on Open Launch Config.
  5. Goto VM arguments.
  6. Add the below two entries.

"-Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager" "-Djava.util.logging.manager=org.jboss.logmanager.LogManager"

Now select the Classpath TAB

  1. Select User Entries
  2. Click Add External Jars
  3. Select the three jar files

a) jboss-logmanager-1.2.0.GA.jar b) jboss-logmanager-log4j-1.0.0.GA.jar c) log4j-1.2.16.jar

Paths

  1. C:/jboss-as-7.1.1.Final/modules/org/jboss/logmanager/main/jboss-logmanager-1.2.0.GA.jar"
  2. C:/jboss-as-7.1.1.Final/modules/org/jboss/logmanager/log4j/main/jboss-logmanager-log4j-1.0.0.GA.jar"
  3. C:/jboss-as-7.1.1.Final/modules/org/apache/log4j/main/log4j-1.2.16.jar"

This will start the standalone jboss without any issues.

In EAP 6.4, the correct logmanager's path should be $JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-1.5.4.Final-redhat-1.jar

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top