ContentsUsing JCL Diagnostics
Diagnostics is a feature introduced in JCL 1.1 as an aid to debugging problems
with JCL configurations. When diagnostics are switched on, messages are logged
to a stream (specified by the user) by the two main classes involved in discovery
in JCL ( Diagnostics are intended to be used in conjunction with the source. The source contains numerous and lengthy comments. Often these are intended to help explain the meaning of the messages. When To Use Diagnostic LoggingDiagnostic logging is intended only to be used when debugging a problematic configuration. It should be switched off for production. How To Use Diagnostic logging
Diagnostic logging is controlled through the system property
OIDs
Diagnostics uses the concept of an Object ID (OID). This allows the identity of objects
to be tracked without relying on useful
The system identity hash code is found by calling
OIDs are intended to be used to cross-reference. They allow particular instances of classloaders and JCL classes to be tracked in different contexts. This plays a vital role in building up the understanding of the classloader environment required to diagnose JCL problems. Diagnostic Message PrefixEach diagnostic message is prefixed with details of the relevant class in a standard format. This takes the form:
ClassLoader OID is the OID of a classloader which loaded the class issuing the message. class-identifier identifies the object issuing the message.
In the case of
In the case of
ClassLoader Hierarchy Tree
Understanding the relationships between classloaders is vital when debugging JCL.
At various points, JCL will print to the diagnostic log the hierarchy for important
classloaders. This is obtained by walking the tree using
Represents a hierarchy with four elements ending in the boot classloader. LogFactory Class Bootstrap
Whenever the
Many Sun classloaders have confusing
with a
Other classloader implementations may give very useful information (such as the local classpath).
Finally, once initialization is complete a Construction Of LogFactoryImpl Instances
Before assigning a The implementation used can vary per Thread context classloader (TCCL). If this is the first time that a Log has been requested for a particular TCCL a new instance will be created.
Information of particular interest is logged at this stage. Details of the TCCL are logged
allowing the OID later to be cross-referenced to the
Log Discovery Diagnostics
The standard
During discovery, environment variables are loaded and values set. This content is prefixed by
The possible messages issued during discovery are numerous. To understand them, the source
should be consulted. Attention should be paid to the classloader hierarchy trees for the
classloader used to load Containers With Custom LogFactory Implementations
Some containers use a custom Containers known to use this mechanism:
Containers suspected to use this mechanism:
The Apache Commons team would be grateful if reports were posted to the development list of other containers using a custom implementation. The Incompatible LogFactory IssueSymptomsAn exception is thrown by JCL with a message similar to:
This is a WebSphere example so the name of the custom LogFactory is
Explanation
A custom
There is also another more unusual way in which this cast can fail: even when the binary is compatible,
the implementation class loaded at runtime may be linked to a different instance of the
This situation may be encountered in containers which use a custom
The policy adopted by JCL in this situation is to re-throw this exception. Additional information
is included in the message to help diagnosis. The reasoning behind this choice is that a
particular FixesThere are various ways to fix this problem. Which fix is right depends on the circumstances.
If you are happy using another classloading policy for the application, select a
classloading policy which ensures that If you want to bypass the container adaption mechanism then set the appropriate system property to the default value when the container is started:
If you want to continue to use the default container mechanism then:
If you encounter difficulties when applying the fixes recommended, please turn on diagnostics and consult the logs. Containers With Custom ClassLoading Behaviour for LoggingBecause commons-logging is such a fundamental library, some containers modify the way in which classloading behaves for commons-logging classes. Apache TomcatAt the current date, Tomcat 5.5.16 is the current release. All releases from version 4.1.x through 5.5.16 have a startup process that places jarfile ${tomcat.home}/bin/commons-logging-api.jar in the system classpath and then prevents any webapp from overriding the classes in that jarfile. Effectively, all webapps behave as if "parent-first" classloading were enabled for those classes. This has some benefits; in particular it means that there are no problems in these Tomcat versions with having multiple copies of the commons-logging Log interface in the classpath (which avoids the "Log does not implement Log" problem described elsewhere). However it also means that no webapp can override the core commons-logging classes by including an updated commons-logging jarfile in WEB-INF/lib; any class already loaded via the container takes priority. In particular, as Tomcat bundles logging 1.0.4 only, the new diagnostics and memory-leak-prevention features of the 1.1 release will not be available unless the container's library version is updated. Because the commons-logging-api.jar in the container does not contain any log-library-adapter classes, updated behavior for these will be seen when logging 1.1 is bundled in WEB-INF/lib. In particular, the support for Log4j's TRACE level will take effect without having to update the container. If you do wish to update Tomcat's version of commons-logging, then you must use the commons-logging-1.1-api jar only, not the full jar. Classes in the webapp cannot override classes loaded from the system classpath set up during Tomcat's startup process, and logging adapters can only see their matching concrete logging library if that library is available in the same classpath. Bundling the full commons-logging jarfile (with adapters) into the system classpath therefore means that logging libraries (eg Log4j) within WEB-INF/lib are not accessible. Note that the behavior described here only applies if the standard Tomcat startup process is run. When Tomcat is embedded in a larger framework (eg run embedded within an IDE) this may not apply. JBoss Application ServerThe JBoss Application Server can be configured to prevent deployed code from overriding classes higher in the hierarchy, effectively forcing "parent-first" behavior for selected classes. By default, commons-logging is in this list (at least for some JBoss versions starting with 4.0.2), and therefore including an updated version of commons-logging in WEB-INF/lib or similar will have no effect. See the JBoss classloading documentation for more details. Other ContainersAs more information becomes available on this topic, it may be added to the commons-logging wiki site. |