Bug 34 - StreamCorruptedException when using SocketAppender
Summary: StreamCorruptedException when using SocketAppender
Status: RESOLVED REMIND
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: 1.0
Hardware: PC All
: P1 major
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-01-12 14:36 UTC by Aston C. Chan
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aston C. Chan 2001-01-12 14:36:31 UTC
I'm using the SocketAppender.  Whenever I try to send a message to the 
logServer, the following stack appears:

C:\temp\foo>java -cp C:\projects\astonc_t2_smp_mainline\aw\classes;C:\projects\A
stonc_t2_smp_mainline\aw\hedzup\lib\log4j.jar org.apache.log4j.net.SocketServer
12345 C:\projects\Astonc_t2_smp_mainline\config\SMPLog.properties C:\temp
01/12/2001 17:18 SocketServer INFO  Listening on port 12345
01/12/2001 17:18 SocketServer INFO  Waiting to accept a new client.
01/12/2001 17:18 SocketServer INFO  Connected to client at 127.0.0.1/127.0.0.1
01/12/2001 17:18 SocketServer INFO  Locating configuration file for 127.0.0.1/12
7.0.0.1
01/12/2001 17:18 SocketServer WARN  Could not find config file [C:\temp\127.0.0.
1.lcf].
01/12/2001 17:18 SocketServer WARN  Could not find config file [C:\temp\generic.
lcf]. Will use the default hierarchy.
01/12/2001 17:18 SocketServer INFO  Starting new socket node.
01/12/2001 17:18 SocketNode ERROR Could not open ObjectInputStream to Socket[add
r=127.0.0.1/127.0.0.1,port=1511,localport=12345]
java.io.StreamCorruptedException: Caught EOFException while reading the stream h
eader
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        at java.io.ObjectInputStream.<init>(Unknown Source)
        at org.apache.log4j.net.SocketNode.<init>(SocketNode.java:52)
        at org.apache.log4j.net.SocketServer.main(SocketServer.java:115)
01/12/2001 17:18 SocketServer INFO  Waiting to accept a new client.
01/12/2001 17:18 SocketServer INFO  Connected to client at 127.0.0.1/127.0.0.1
01/12/2001 17:18 SocketServer INFO  Locating configuration file for 127.0.0.1/12
7.0.0.1
01/12/2001 17:18 SocketServer WARN  Could not find config file [C:\temp\127.0.0.
1.lcf].
01/12/2001 17:18 SocketServer INFO  Starting new socket node.
01/12/2001 17:18 SocketServer INFO  Waiting to accept a new client.
01/12/2001 17:18 SocketNode ERROR Unexpected exception. Closing conneciton.
java.lang.NullPointerException
        at org.apache.log4j.net.SocketNode.run(SocketNode.java:71)
        at java.lang.Thread.run(Unknown Source)
01/12/2001 17:18 SocketNode INFO  Could not close connection.
java.lang.NullPointerException
        at org.apache.log4j.net.SocketNode.run(SocketNode.java:89)
        at java.lang.Thread.run(Unknown Source)
01/12/2001 17:18 dsamanager INFO  DSAManagerImpl called


After that, everything seems to work fine.

Thanks.

-Aston
Comment 1 Aston C. Chan 2001-01-12 14:42:15 UTC
One more comment.  On the client side, I'm getting the RootCategory and adding 
the SocketAppender to it.  I'm doing it because my port is dynamic so I can't 
specify it in the property file.  Instead, I'm creating the SocketAppender by 
using the hostname and port #.  Many thanks.  -Aston
Comment 2 BugZilla Maintainer Account 2001-01-12 15:19:49 UTC
Aston,

The errors show that on the server side the ObjectInputStream creation failed. 
I do not know the reason for this but I very much doubt that the server logs 
anything coming from the client.

Which Operating System and JDK is this?  Ceki
Comment 3 BugZilla Maintainer Account 2001-01-13 00:31:18 UTC
I think I know what the problem is. Try invoking Category.shutdown before you 
exit the application (on the client side). That should do it. Ceki

ps: Let me know the results so that I can close this bug report.
Comment 4 Aston C. Chan 2001-01-15 06:28:12 UTC
Ceki,

First, I didn't use the SocketServer as my remote server.  Instead, I created a 
ServerSocket myself and called SocketNode directly.  In my server code, I tried 
to check for the existing of the Socket.  If failed, I'll start the server 
myself.  Here is how I did it:

Socket socket = new Socket(host, port);

It triggered the exception.

Instead of trying to open a socket, I now do:

ObjectOutputStream oos = new ObjectOutputStream(new Socket(host, 
port).getOutputStream());

It worked like a charm!

Thanks.

-Aston