The problem is occurring during a sanity check test in instantiateByClassName method 
defined in the org.apache.log4j.helpers.OptionConverter class.

For whatever reason the isAssignableFrom method (see code below) is returning false, 
i.e it is claiming that org.apache.log4j.RollingFileAppender cannot be assigned to a 
org.apache.log4j.Appender variable. This is clearly true and the test should succeed. 
Could it be an EJB server problem? Which EJB container is this?

Regards, Ceki

The relevant code is copied below:

/**
   Instantiate an object given a class name. Check that the
   <code>className</code> is a subclass of <code>superClass</code>.
*/
public
static
Object instantiateByClassName(String className, Class superClass,
                                Object defaultValue) {
  if(className != null) {
    try {
      Class classObj = Class.forName(className);
      if(!superClass.isAssignableFrom(classObj)) 
        LogLog.error("A \""+className+"\" object is not assignable to a \""+
               superClass.getName() + "\" object.");
        return classObj.newInstance();
      }
      catch (Exception e) {
      LogLog.error("Could not instantiate class [" + className + "].", e);
    }
  }
  return defaultValue;    
}



At 14:53 22.03.2001 +0000, Gareth Powell wrote:
>Hi all,
> 
>    I have been using Log4j for a short while and have now started to introduce it to 
>my EJB development however I am getting an exception when calling 
>PropertyConfigurator with a property file loaded from the system. Here's the 
>exception I'm getting:
> 
>log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not assignable to a 
>"org.apache.log4j.Appender" object.
>Exception: org.apache.log4j.RollingFileAppender
>java.lang.ClassCastException: org.apache.log4j.RollingFileAppender
> at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:574)
> at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:555)
> at 
>org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:462)
> at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:388)
> at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:332)
> 
>The property file is being loaded ok, but as soon as the property object if passed to 
>the PropertyConfigurator it bombs with the above exception.
>The same code works fine outside of an EJB. Has anybody used log4j with EJBs and can 
>help.
> 
>Thanks in advance.
> 
>Best Regards,
> 
>Gareth Powell
> 
>------------------------------------------------------------------------
>Gareth Powell BSc. (Hons)
>Java Software Engineer
>TriNet IMB Ltd
>Orchard House
>Castle Garth
>Kendal
>Cumbria
>LA9 7AT
><http://www.trinetimb.com/>www.trinetimb.com
>t : +44 (0) 1539 731000
>f : +44 (0) 1539 729995
> 
> 


I hope to see you at my ApacheCon 2001 presentation 
entitled "Log4j, A Logging Package for Java".

See http://ApacheCon.Com/2001/US/ for more details.

----
Ceki Gülcü          Web:   http://qos.ch     
av. de Rumine 5     email: [EMAIL PROTECTED] (preferred)
CH-1005 Lausanne           [EMAIL PROTECTED]
Switzerland         Tel: ++41 21 351 23 15


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

Reply via email to