org.springframework.osgi.util
Class DebugUtils

java.lang.Object
  extended by org.springframework.osgi.util.DebugUtils

public abstract class DebugUtils
extends Object

Utility class used for debugging exceptions in OSGi environment, such as class loading errors. The main entry point is debugClassLoadingThrowable(Throwable, Bundle, Class[]) which will try to determine the cause by trying to load the given interfaces using the given bundle.

The debugging process can be potentially expensive.

Author:
Costin Leau, Andy Piper

Constructor Summary
DebugUtils()
           
 
Method Summary
static void debugClassLoading(Bundle bundle, String className, String rootClassName)
          Tries (through a best-guess attempt) to figure out why a given class could not be found.
static void debugClassLoadingThrowable(Throwable loadingThrowable, Bundle bundle, Class<?>[] classes)
          Tries to debug the cause of the Throwables that can appear when loading classes in OSGi environments (for example when creating proxies).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DebugUtils

public DebugUtils()
Method Detail

debugClassLoadingThrowable

public static void debugClassLoadingThrowable(Throwable loadingThrowable,
                                              Bundle bundle,
                                              Class<?>[] classes)
Tries to debug the cause of the Throwables that can appear when loading classes in OSGi environments (for example when creating proxies).

This method will try to determine the class that caused the problem and to search for it in the given bundle or through the classloaders of the given classes. It will look at the classes are visible by the given bundle on debug level and do a bundle discovery process on trace level. The method accepts also an array of classes which will be used for loading the 'problematic' class that caused the exception on debug level.

Parameters:
loadingThrowable - class loading Throwable (such as NoClassDefFoundError or ClassNotFoundException)
bundle - bundle used for loading the classes
classes - (optional) array of classes that will be used for loading the problematic class

debugClassLoading

public static void debugClassLoading(Bundle bundle,
                                     String className,
                                     String rootClassName)
Tries (through a best-guess attempt) to figure out why a given class could not be found. This method will search the given bundle and its classpath to determine the reason for which the class cannot be loaded.

This method tries to be effective especially when the dealing with NoClassDefFoundError caused by failure of loading transitive classes (such as getting a NCDFE when loading foo.A because bar.B cannot be found).

Parameters:
bundle - the bundle to search for (and which should do the loading)
className - the name of the class that failed to be loaded in dot format (i.e. java.lang.Thread)
rootClassName - the name of the class that triggered the loading (i.e. java.lang.Runnable)


Copyright © 2006-2011 Spring Framework. All Rights Reserved.