Hi!
I try to describe my problem. I have to use instance of org.apache.commons.logging.Log in my components instead of Logger. So I've created my implementation of org.apache.avalon.logging.provider.LoggingManager. This implementation instantiates another LoggingManager implementation and wraps produced Logger instance. My wrapper implements both Logger and Log interfaces:


public class LogLogger implements Log, Logger{
  protected Logger logger = null;

  public LogLogger(Logger logger) {
    this.logger = logger;
  }

  public boolean isTraceEnabled() {
    return logger.isDebugEnabled();
  }

  public boolean isDebugEnabled() {
    return logger.isDebugEnabled();
  }
.....
}

So I can cast it to Log in my component:
  Log myLogger;
  public void enableLogging(Logger logger) {
    myLogger = (Log)logger;
  }

But unfortunately a get the following exception:

java.lang.ClassCastException
net.softwarium.commons.logger.avalon.TestComponent.enableLogging(TestComponent.java:47)
org.apache.avalon.activation.appliance.impl.DefaultAppliance.applyLogger(DefaultAppliance.java:545)

I discoved the cause of the exception is that Log class for LoggingManager and Log class for Component lay in distinct classloaders:

LoggingManager ClassLoader ---> Log ClassLoader ---> Merlin Impl ClassLoader --->.....
MyComponent ClassLoader ---> LogClassLoader ---> Merlin Impl ClassLoader --> ....


but I can't imagine how I can reapir this situation :(


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to