You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Marvin Chase <Ma...@GFInet.com> on 2002/06/10 19:17:35 UTC

LoggingEvent ClassCastException

Guys,

I'm experiencing a strange class cast exception when deserializing a
LoggingEvent.  This exception does not occur consistently.  I have
implemented a custom JMSAppender which sends log messages (LoggingEvent
classes) 
via JMS.  Many times the app will operate without exception, but sometimes
exceptions will
occur in the same code that previously ran perfectly.  The stack trace is
below.

This ClassCastException is occurring while assigning the categoryName (a
String)
during deserialization.  Note that my server in Weblogic 5.1.  Has anyone 
seen this error before?

Thanks..

java.lang.ClassCastException: Assigning instance of class java.lang.String
to field org.apache.log4j.spi.LoggingEvent#categoryName
        at
java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2271)
        at
java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:519)
        at
org.apache.log4j.spi.LoggingEvent.readObject(LoggingEvent.java:322)
        at java.lang.reflect.Method.invoke(Native Method)
        at
java.io.ObjectInputStream.invokeObjectReader(ObjectInputStream.java:2214)
        at
java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1411)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
        at
weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.java:76)
        at
com.my.platform.servers.log.JMSSink.onMessage(JMSSink.java:90)
        at
weblogic.jms.client.JMSMessageConsumer.readQueue(JMSMessageConsumer.java:358
)
        at weblogic.jms.common.MessageQueue.execute(MessageQueue.java:761)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)


***************************************************************
Confidentiality note: This e-mail contains information from the 
GFI Group Inc. and/or its affiliates, including GFInet inc., 
that is confidential and/or legally privileged.   This 
information is intended only for the use of the individual or 
entity named on this e-mail.  This e-mail and its content may 
not be reproduced or retransmitted without the express written 
permission of The GFI Group.
***************************************************************


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re[2]: Logging while initializing config file question...

Posted by Jacob Kjome <ho...@visi.com>.
Thanks, that is good information that I didn't know.

However, what if I want to
put out my own messages within my init servlet.  This is before any
calls to configure().  I do a bunch of checking to make sure that file
path passed to the servlet exists and whether the webapp is running
off the filesystem or directly from a .war file.

In that case, is my only option System.out.println(String)?

Jake



Monday, June 10, 2002, 1:11:53 PM, you wrote:

TTM> Assuming that you're using XMLConfigurator, you can use the following
TTM> adjuration in your config file:

TTM> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'
TTM>                 debug="true" threshold="debug">

TTM> This will cause Log4j to issue log statements to System.out during
TTM> initialization and at some other occasions (e.g. when files roll etc). Error
TTM> messages will be dumped to System.err irrespective of debug set to true or
TTM> not. All Log4j messages to System err/out are prefixed with 'LOG4j:'

TTM> Hope this helps.

TTM> --

TTM> Thomas


TTM> | -----Original Message-----
TTM> | From: Jacob Kjome [mailto:hoju@visi.com]
TTM> | Sent: 10 June 2002 19:03
TTM> | To: Log4J Users List
TTM> | Subject: Logging while initializing config file question...
TTM> |
TTM> |
TTM> |
TTM> | What does one do during configuration of Log4j?  For instance, when
TTM> | one calls PropertyConfigurator.configure(file) or
TTM> | PropertyConfigurator.configureAndWatch(file), what kind of logging is
TTM> | available to see what is happening during this?  Do you just bite but
TTM> | bullet and do System.out.println(String)?
TTM> |
TTM> | Jake
TTM> |
TTM> |
TTM> | --
TTM> | To unsubscribe, e-mail:
TTM> | <ma...@jakarta.apache.org>
TTM> | For additional commands, e-mail:
TTM> | <ma...@jakarta.apache.org>
TTM> |
TTM> |



TTM> *************************************************************************
TTM> Copyright ERA Technology Ltd. 2002. (www.era.co.uk). All rights reserved. 
TTM> The information supplied in this email should be treated in confidence.
TTM> No liability whatsoever is accepted for any loss or damage 
TTM> suffered as a result of accessing this message or any attachments.

TTM> ________________________________________________________________________
TTM> This email has been scanned for all viruses by the MessageLabs SkyScan
TTM> service. For more information on a proactive anti-virus service working
TTM> around the clock, around the globe, visit http://www.messagelabs.com
TTM> ________________________________________________________________________

TTM> --
TTM> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
TTM> For additional commands, e-mail: <ma...@jakarta.apache.org>



-- 
Best regards,
 Jacob                            mailto:hoju@visi.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Logging while initializing config file question...

Posted by Thomas Tuft Muller <tt...@online.no>.
Assuming that you're using XMLConfigurator, you can use the following
adjuration in your config file:

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'
		debug="true" threshold="debug">

This will cause Log4j to issue log statements to System.out during
initialization and at some other occasions (e.g. when files roll etc). Error
messages will be dumped to System.err irrespective of debug set to true or
not. All Log4j messages to System err/out are prefixed with 'LOG4j:'

Hope this helps.

--

Thomas


| -----Original Message-----
| From: Jacob Kjome [mailto:hoju@visi.com]
| Sent: 10 June 2002 19:03
| To: Log4J Users List
| Subject: Logging while initializing config file question...
|
|
|
| What does one do during configuration of Log4j?  For instance, when
| one calls PropertyConfigurator.configure(file) or
| PropertyConfigurator.configureAndWatch(file), what kind of logging is
| available to see what is happening during this?  Do you just bite but
| bullet and do System.out.println(String)?
|
| Jake
|
|
| --
| To unsubscribe, e-mail:
| <ma...@jakarta.apache.org>
| For additional commands, e-mail:
| <ma...@jakarta.apache.org>
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2002. (www.era.co.uk). All rights reserved. 
The information supplied in this email should be treated in confidence.
No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Logging while initializing config file question...

Posted by Jacob Kjome <ho...@visi.com>.
What does one do during configuration of Log4j?  For instance, when
one calls PropertyConfigurator.configure(file) or
PropertyConfigurator.configureAndWatch(file), what kind of logging is
available to see what is happening during this?  Do you just bite but
bullet and do System.out.println(String)?

Jake


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: LoggingEvent ClassCastException

Posted by Steve Ebersole <st...@austin.rr.com>.
I have used log4j to send LoggingEvent object through JMS to Weblogic 5.10,
6.0, and 6.1, but have never seen a problem such as this.

Not quite sure what you mean by "assigning the categoryName ... during
deserialization".  What are the steps you are performing when this occurs?

----- Original Message -----
From: "Marvin Chase" <Ma...@GFInet.com>
To: <lo...@jakarta.apache.org>
Sent: Monday, June 10, 2002 12:17 PM
Subject: LoggingEvent ClassCastException


> Guys,
>
> I'm experiencing a strange class cast exception when deserializing a
> LoggingEvent.  This exception does not occur consistently.  I have
> implemented a custom JMSAppender which sends log messages (LoggingEvent
> classes)
> via JMS.  Many times the app will operate without exception, but sometimes
> exceptions will
> occur in the same code that previously ran perfectly.  The stack trace is
> below.
>
> This ClassCastException is occurring while assigning the categoryName (a
> String)
> during deserialization.  Note that my server in Weblogic 5.1.  Has anyone
> seen this error before?
>
> Thanks..
>
> java.lang.ClassCastException: Assigning instance of class java.lang.String
> to field org.apache.log4j.spi.LoggingEvent#categoryName
>         at
> java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2271)
>         at
> java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:519)
>         at
> org.apache.log4j.spi.LoggingEvent.readObject(LoggingEvent.java:322)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at
> java.io.ObjectInputStream.invokeObjectReader(ObjectInputStream.java:2214)
>         at
> java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1411)
>         at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
>         at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
>         at
> weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.java:76)
>         at
> com.my.platform.servers.log.JMSSink.onMessage(JMSSink.java:90)
>         at
>
weblogic.jms.client.JMSMessageConsumer.readQueue(JMSMessageConsumer.java:358
> )
>         at weblogic.jms.common.MessageQueue.execute(MessageQueue.java:761)
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
>
>
> ***************************************************************
> Confidentiality note: This e-mail contains information from the
> GFI Group Inc. and/or its affiliates, including GFInet inc.,
> that is confidential and/or legally privileged.   This
> information is intended only for the use of the individual or
> entity named on this e-mail.  This e-mail and its content may
> not be reproduced or retransmitted without the express written
> permission of The GFI Group.
> ***************************************************************
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>