JBoss 6.x

Problem with JBoss Logging

With the JBoss version 6 and above there is the problem with the logging when an agent that uses the java.util.logging is started with the JBoss. This problem is filled as the bug on the JBoss issue tracking system. "This is because the java agent does not have access to jboss-logmanager classes, so even if the java.util.logging.manager property is set the classes will not be available." The problem will appear when inspectIT is used as the agent:

DEPLOYMENTS IN ERROR:
  Deployment "JBossLog4jRepostiorySelector" is in error due to the following reason(s): java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager")
  Deployment "JBossLogService" is in error due to the following reason(s): java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager"), **ERROR**
	at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1228)
	at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:905)
	at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.checkComplete(MainDeployerPlugin.java:87)
	at org.jboss.profileservice.deployment.ProfileDeployerPluginRegistry.checkAllComplete(ProfileDeployerPluginRegistry.java:107)
	at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:135)
	at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56)
	at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827)
	at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417)
	at java.lang.Thread.run(Thread.java:724)

This page describes how to set up the JBoss 6.x with the inspectIT agent and overcome the problem.

Problem with Custom Logging Module

If a custom logging module is used with JBoss 6.x, JBoss throws the following exception at startup with the inspectIT agent:

java.lang.IllegalArgumentException: Failed to load module "de.myLoggingModule.logging" for handler "CUSTOM_HANDLER"
	at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:64)
	at org.jboss.logmanager.config.HandlerConfigurationImpl.<init>(HandlerConfigurationImpl.java:51)
	at org.jboss.logmanager.config.LogContextConfigurationImpl.addHandlerConfiguration(LogContextConfigurationImpl.java:142)
	at org.jboss.logmanager.PropertyConfigurator.configureHandler(PropertyConfigurator.java:666)
	at org.jboss.logmanager.PropertyConfigurator.configureLogger(PropertyConfigurator.java:576)
	at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:514)
	at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:94)
	at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:493)
	at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:455)
	at java.util.logging.LogManager$3.run(LogManager.java:399)
	at java.util.logging.LogManager$3.run(LogManager.java:396)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:396)
	at java.util.logging.LogManager.access$800(LogManager.java:145)
	at java.util.logging.LogManager$2.run(LogManager.java:345)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.util.logging.LogManager.ensureLogManagerInitialized(LogManager.java:338)
	at java.util.logging.LogManager.getLogManager(LogManager.java:378)
	at java.util.logging.Logger.demandLogger(Logger.java:448)
	at java.util.logging.Logger.getLogger(Logger.java:502)
	at rocks.inspectit.agent.java.javaagent.JavaAgent.<clinit>(JavaAgent.java:53)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
	at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.NoClassDefFoundError: org/jboss/modules/ModuleLoader
	at org.jboss.logmanager.config.AbstractPropertyConfiguration$ModuleFinder.getClassLoader(AbstractPropertyConfiguration.java:463)
	at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:62)
	... 26 more

Add the following configuration to the JAVA_OPTS to solve this problem:

JAVA_OPTS="$JAVA_OPTS -Dmodule.path=$JBOSS_HOME/modules"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/jboss-modules.jar"


Configuration

The configuration is quite simple. Only needed thing is to edit the run.conf file (if you start with run start script).

At the beginning of the file add the following line:

# Added for logging problem
JBOSS_MODULES_SYSTEM_PKGS="org.jboss.logmanager"

At the end of the file add the following to solve the logging problem:

# Added for logging problem
JBOSS_HOME="[path-to-jboss-folder]"
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/p:$JBOSS_HOME/lib/jboss-logmanager.jar -Xbootclasspath/p:$JBOSS_HOME/common/lib/jboss-logmanager-log4j.jar -Xbootclasspath/p:$JBOSS_HOME/common/lib/log4j.jar"

Above paths to JAR files relate to JBoss version 6.1.0. If you are using the older version please make sure that the paths to JARs are correct.

At the end of the file we can also integrate the inspectIT related options:

# inspectIT Settings
INSPECTIT_AGENT_HOME="[path-to-inspectit-agent-home]"
INSPECTIT_JAVA_OPTS="-Xbootclasspath/p:${INSPECTIT_AGENT_HOME}/inspectit-agent.jar -javaagent:${INSPECTIT_AGENT_HOME}/inspectit-agent.jar -Dinspectit.repository=[REPOSIOTRY_IP]:[REPOSITORY_PORT] -Dinspectit.agent.name=[AGENT_DISPLAY_NAME]"
JAVA_OPTS="${INSPECTIT_JAVA_OPTS} ${JAVA_OPTS}"