Bug 31178 - Exception using Chainsaw for simple debugging
Summary: Exception using Chainsaw for simple debugging
Status: NEEDINFO
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: chainsaw (show other bugs)
Version: 1.2
Hardware: Other Windows XP
: P3 critical
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-11 18:34 UTC by Christian Ashby
Modified: 2008-08-03 02:59 UTC (History)
4 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Ashby 2004-09-11 18:34:17 UTC
See below for error, log4j.properties entries, etc.

ClassNotFoundException is thrown in chainsaw when trying to use a default 
SocketAppender and SimpleListener.

Chainsaw v2.0alpha loaded via WebStart on JDK 1.4.2 IE 6 Windows XP SP2, log4j 
version 1.2.8

Tried reinstall of jdk, jvm and chainsaw

Exception thrown:
-----------------
Level
ERROR
Logger
org.apache.log4j.net.SocketNode
Time
2004-09-11 11:09:18,046
Thread
Thread-10
Message
Unexpected exception. Closing connection.
NDC
null
Class

Method

Line

File

Properties
{{log4jid,1}}
Throwable
java.lang.ClassNotFoundException: org.apache.log4j.spi.LocationInfo
	at com.sun.jnlp.JNLPClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Unknown Source)
	at java.io.ObjectInputStream.resolveClass(Unknown Source)
	at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
	at java.io.ObjectInputStream.readClassDesc(Unknown Source)
	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
	at java.io.ObjectInputStream.readObject0(Unknown Source)
	at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
	at java.io.ObjectInputStream.defaultReadObject(Unknown Source)
	at org.apache.log4j.spi.LoggingEvent.readObject(LoggingEvent.java:848)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
	at java.io.ObjectInputStream.readSerialData(Unknown Source)
	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
	at java.io.ObjectInputStream.readObject0(Unknown Source)
	at java.io.ObjectInputStream.readObject(Unknown Source)
	at org.apache.log4j.net.SocketNode.run(SocketNode.java:134)
	at java.lang.Thread.run(Unknown Source)

Properties file:
----------------
# Set root logger level to DEBUG and its appenders to stdout and R.
log4j.rootLogger=debug, stdout, R, Socket

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
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] (%c\:%L) - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=c:/spl_log4j.log
log4j.appender.R.MaxFileSize=512KB
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

log4j.appender.Socket=org.apache.log4j.net.SocketAppender
log4j.appender.Socket.RemoteHost=localhost
log4j.appender.Socket.Port=4445

Test class for debugging:
-------------------------
public class test {

	public static void main( String[] args ) {
		org.apache.log4j.Logger.getLogger("test class").debug("Testing 
logging");
	}
}

(Class being compiled & run with just log4j in the classpath)
(log4j.properties is being read correctly)

Output in file that is logged (works as expected)
-----------------------------
DEBUG main test class - Testing logging
Comment 1 Paul Smith 2004-09-12 22:16:33 UTC
This would be because of a package reshuffle in the core log4j library.  It has 
been recently resovled.

The new web start version uploaded as of 2004-09-13 08:30 GMT+10 should have 
this fixed.
Comment 2 Christian Ashby 2004-09-12 23:45:30 UTC
Doesn't work on the version on the site as of 1600 GMT-8
Comment 3 Paul Smith 2004-09-13 00:04:01 UTC
Working for me... Has your webstart loaded the new version?  (sometimes it only 
checks every other launch).
Comment 4 Christian Ashby 2004-09-13 02:13:15 UTC
The version I have (and that installed cleanly for the first time on a virgin 
system) is 1.99.99 (According to the release notes)

I see the error on both machines.
Comment 5 Scott Deboy 2004-09-13 21:59:44 UTC
As a workaround, you can take the 'locationinfo' param out of the layout and
events should load correctly in Chainsaw.
Comment 6 Christian Ashby 2004-09-13 23:27:49 UTC
If I understand correctly, org.apache.log4j.net.SocketAppender doesn't use a 
layout, right?

If so, how do I remove locationInfo?
Comment 7 Scott Deboy 2004-09-14 00:20:00 UTC
LocationInfo should be off by default.

To explicitly disable, add a locationInfo param to the socketappender config:
<param name="LocationInfo" value="false"/>
Comment 8 David Cowan 2004-09-14 16:22:45 UTC
I have tried setting locationInfo=false and I still see this problem.  This is 
only after webstart updated from the previous version to 2.0alpha
Comment 9 Scott Deboy 2004-09-14 20:42:48 UTC
The setting of locationInfo on the appender sets a boolean.

Are you using log4j 1.2.8?  I've tested and verified that if you using a
SocketAppender from log4j1.2.8 you can send events to Chainsaw V2.  

I was able to reproduce the classnotfoundexception only by explicitly setting
the LocationInfo param to true.  Setting this param explicitly to false, while
unnecessary, resulted in the events successfully getting loaded by Chainsaw V2.

Here is a link to the source (this is a link to the 1.2.7 tagged version):
http://cvs.apache.org/viewcvs.cgi/logging-log4j/src/java/org/apache/log4j/net/SocketAppender.java?rev=1.12.2.1&view=markup

Note that the locationInfo boolean is used in the 'append' method.

If you are not using log4j 1.2.8 on the appender side, give us more information
on your configuration and we can reopen.
Comment 10 Scott Deboy 2004-09-14 22:13:34 UTC
This is actually a workaround and probably shouldn't be marked as closed without
discussing whether or not we want to provide serial backward-compatibility with
log4j 1.2.8.
Comment 11 Christian Ashby 2004-09-15 13:07:35 UTC
Not only is this a workaround, it's also broken against the current stable 
release of its parent product.

Some testing of the log4j version must be done before this bug can be closed at 
least until log4j 1.2.8 becomes an archive rather than production / stable 
release.
Comment 12 Scott Deboy 2004-09-15 14:20:20 UTC
As I mentioned, I can use the log4j 1.2.8 SocketAppender to send events to
Chainsaw V2 - it is only when I explicitly set the locationInfo parameter to
false that I get the error.

Would you mind attaching your appender configuration file?

I would like to ensure we can at least provide a temporary solution to folks
using log4j1.2.8 and SocketAppender with Chainsaw V2 while we work through
compatibility issues.
Comment 13 Scott Deboy 2004-09-15 14:22:13 UTC
correction of previous entry - I am able to reproduce the problem only when
explicitly setting the locationInfo param on SocketAppender to TRUE
Comment 14 Christian Ashby 2004-09-15 14:22:45 UTC
The properties file is included in my original report

(I'm not yet using XML configuration)
Comment 15 Greg Emerick 2004-09-15 14:25:06 UTC
I am having the same problem.  I am using log4j1.2.8 on the appender side.  
Leaving out locationInfo or setting it to false has no affect.  

The test case supplied with this bug proves it very nicely.

It appears that if I remove the stdout conversionPattern property, the 
locationinfo exception goes away.  %L seems to be the offending parameter in 
the conversion pattern.
Comment 16 Scott Deboy 2004-09-15 14:42:19 UTC
Nice work.  

One easier workaround (since appenders are processed in order), is set the
SocketAppender as the first appender - the LocationInfo won't be set until the
FileAppender is processed, so the SocketAppender will work fine but not have the
LocationInfo:

log4j.rootLogger=debug, stdout, Socket, R
Comment 17 Christian Ashby 2004-09-15 22:05:11 UTC
Doing this works just fine for me.

Thanks for your support guys, and I hope a fix gets added soon!
Comment 18 Kuki Szabolcs 2005-01-14 19:29:45 UTC
I just want to let you know that this problem is still active, I've taken the
latest chainsaw code (using install-chainsaw.xml) + WebStart, tested with jdk
1.4.2. 

For SocketAppender I tested with log4j 1.2.8, 1.2.9, 1.3alpha.
I had beside the SocketApender an XMLLayot with locationInfo set

log4j.appender.fileXMLTARGET.layout=org.apache.log4j.xml.XMLLayout
log4j.appender.fileXMLTARGET.layout.LocationInfo=true

log4j.appender.CHAINSAW_CLIENT=org.apache.log4j.net.SocketAppender
log4j.appender.CHAINSAW_CLIENT.RemoteHost=127.0.0.1
log4j.appender.CHAINSAW_CLIENT.Port=4445
log4j.appender.CHAINSAW_CLIENT.LocationInfo=false

Changing the order (placing fileXMLTARGET after CHAINSAW_CLIENT) solved the
problem, any location information before the Appender will generate this exception.

As an ideea check where org.apache.log4j.spi.LocationInfo is refered and try to
fix it, so it would refer to org.apache.log4j.spi.location.LocationInfo.

Thanks for the great job :).
Comment 19 Thorbjørn Ravn Andersen 2008-06-30 12:51:37 UTC
Is this bug still a problem?  I have used chainsaw a bit recently and not seen this issue?