jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: LogConfigurationException due to ClassCastException in commons-logging
Date Thu, 15 Aug 2002 14:31:39 GMT
Hi Kevin,

I have solved the problem, which is not a Cactus issue. However, I will
add it to the Cactus FAQ as it may be useful for others.

Here is an extract of the JUnit FAQ:

"
I get a ClassNotFoundException when I use the LoadingTestRunner
The LoadingTestRunner uses a custom class loader to reload your code.
This class loader doesn't attempt to load classes from jars or to load
standard classes. Instead you can specify a list of excluded package
prefixes that shouldn't be reloaded for each test run. The list of
package prefixes is defined in the properties file
junit.runner.excluded.properties. As we deliver it this file excludes
the packages that come with jdk1.2 from reloading: 

# 
# The list of excluded package paths for the TestCaseClassLoader 
# 
excluded.0=sun.* 
excluded.1=com.sun.* 
excluded.2=org.omg.* 
excluded.3=javax.* 
excluded.4=sunw.*

If you are using additional jars from 3rd party vendors you can either: 
- update this file in the junit.jar and add your package paths or, 
- "patch" the junit.util.excluded.properties file with the CLASSPATH,
that is, put your customized version of this file in the class path
before the junit.jar. In this way your version will be loaded instead of
the one that comes with JUnit.
"

What it means is that the text runner does use that special class
loader. So in summary, create the excluded.properties in your client
side classpath. Here is an example of the file that works for me:

excluded.0=sun.* 
excluded.1=com.sun.* 
excluded.2=org.omg.* 
excluded.3=javax.* 
excluded.4=sunw.*
excluded.5=org.apache.commons.logging.*
excluded.6=java.*

Cheers,
-Vincent

> -----Original Message-----
> From: Wang, Kevin [mailto:KWang@TMRS.org]
> Sent: 14 August 2002 21:03
> To: 'Cactus Users List'
> Subject: RE: LogConfigurationException due to ClassCastException in
> commons-logging
> 
> Vincent,
> 
> Please find the attached very simple package that I used to test
> Cactus-1.2-1.4b1. However, I got the same LogConfigurationException
from
> running the sample test that came with Cactus. The exception occurs
only
> with running junit.swingui.TestRunner and awtgui.TestRunner.
> junit.textui.TestRunner and
> org.apache.cactus.server.runner.ServletTestRunner (via browser) both
run
> without exceptions.
> 
> Thanks.
> Kevin Wang
> 
> -----Original Message-----
> From: Vincent Massol [mailto:vmassol@octo.com]
> Sent: Wednesday, August 14, 2002 2:13 AM
> To: 'Cactus Users List'
> Subject: RE: LogConfigurationException due to ClassCastException in
> commons-logging
> 
> 
> Hum, I haven't found the answer to this yet. BTW you may not need a
> commons-logging properties file at all. Simply have log4j in your
> classpath and it will work (I think - At least it does for me). I will
> give it a try with the commons-logging properties to see if that is
the
> issue (but it shouldn't).
> 
> Would you have a fully packaged sample project that I could use to
> reproduce the bug ?
> 
> Thanks
> -Vincent
> 
> > -----Original Message-----
> > From: Wang, Kevin [mailto:KWang@TMRS.org]
> > Sent: 13 August 2002 16:25
> > To: 'cactus-user@jakarta.apache.org'
> > Subject: LogConfigurationException due to ClassCastException in
> commons-
> > logging
> >
> > Hello,
> >
> > I am getting a LogConfigurationException when trying to run a
servlet
> test
> > case...
> >
> > org.apache.commons.logging.LogConfigurationException:
> > java.lang.ClassCastException:
> > org.apache.commons.logging.impl.LogFactoryImpl
> > at
> org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:505)
> > at
> org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:340)
> > at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:381)
> at
> >
org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:188)
> >
> > It looks like a simple logging config problem. However, the logging
> works
> > well by itself.
> >
> > Here is my cactus.properties:
> > cactus.contextURL=http://localhost:8080/NextGenWebTest
> > cactus.servletRedirectorName=ServletRedirector
> > cactus.jspRedirectorName=JspRedirector
> >
> > commons-logging.properties:
> >
>
#org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLo
> g
> >
>
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JCate
> go
> > ry
> > Log
> >
> > log4j.properties:
> > # A sample log4j configuration file
> >
> > # Create two appenders, one called stdout and the other called
rolling
> > log4j.rootLogger=DEBUG, stdout, rolling
> >
> > # Configure the stdout appender to go to the Console
> > log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> >
> > #  Configure the stdout appender to use the PatternLayout
> > log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> >
> > # Pattern to output the caller's file name and line number.
> > log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) -
%m%n
> >
> > # Configure the rolling appender to be a RollingFileAppender
> > log4j.appender.rolling=org.apache.log4j.RollingFileAppender
> >
> > # Configure the name of the logout for the rolling appender
> > log4j.appender.rolling.File=output.log
> >
> > # Set up the maximum size of the rolling log file
> > log4j.appender.rolling.MaxFileSize=100KB
> >
> > # Keep one backup file of the rolling appender
> > log4j.appender.rolling.MaxBackupIndex=1
> >
> > # Configure the Layout pattern and conversion pattern for the
rolling
> > appender
> > log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
> > log4j.appender.rolling.layout.ConversionPattern=%d{ABSOLUTE} - %p %c
-
> > %m%n
> >
> > Thanks.
> >
> >
> > --
> > To unsubscribe, e-mail:   <mailto:cactus-user-
> > unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: <mailto:cactus-user-
> > help@jakarta.apache.org>
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:cactus-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:cactus-user-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message