Hi Curt,

Thanks for the suggestion. I am not familiar with class loaders so did not think it would be needed info.

Indeed, I am in an environment where multiple classloaders are probably used. Possibly since I am starting my main java program through Eclipse's equinox. Equinox provides a sophisticated bundling system which uses custom classloader for sure. With your pointer, I will have to dig further into Equinox bundle loading to see if a the log4j.jar is being loaded twice.

I am starting running the code through eclipse, and the main looks like this:
   public static void main(String[] args) {
       System.getProperties().put("JavaAgentLogConfigFile",
               "C:\\prototype\\log4j.xml");
       String[] launcherArgs = {
               "-configuration",
               "C:\\prototype\\configuration",
               "-install",
               "C:\\prototype",
"-DJavaAgentLogConfigFile=C:\\OracleATS2\\OFT\\jagent\\log4j-commandline.xml"};
       org.eclipse.core.launcher.Main.main(launcherArgs);
   }
The directory point to an instance of eclipse install. I am configuring this one since the eclipse environment has all the required plugins including the log4j bundles.

If anyone has some pointer on how to debug a environment like this, please let me know. I am just running this in eclipse debug mode.

Regards,
Tom

Curt Arnold wrote:

On Nov 4, 2008, at 1:32 PM, Tom Hsu wrote:

Hi experts,

I am using a an xml document to configure the Log4j from apache. However, I am seeing an class cast exception when I try to run my Java program which configures the log4j through a xml document. The trace is attached. I don't understand the following 2 errors: 1. java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender 2.log4j:ERROR Could not parse input source [EMAIL PROTECTED]
java.lang.NullPointerException

I am sure that the xml is well-formed because I was able to use that xml in an existing system. I have also attached the xml config file. If anyone can provide some pointers, it'd be greatly appreciated!


You don't mention the environment that you are running the code in, but it would appear that you have multiple class loaders and that is causing the cast from ConsoleAppender to Appender to fail. The ClassCastException results in the NullPointerException that occurs later. Please check if you have multiple log4j.jar's in your installation.


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


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

Reply via email to