Hi,

I just had a phone call with Ceki. 

The problem was that I had two instances of my application with exactly 
the same log4j config.
By using a TelnetAppender only the first could create a socket and the 
second failed because the port was already in use.
The same for the RollingFileAppender, normally two jvm can not write to 
the same file. 

The solution is to avoid having multiple applications with the same log 
config by :

a) adapt the config in runtime e.g. increment the port and use a timestamp 
for the log file. Haven't done this yet, so I don't have an example.

b) avoid having multiple applications e.g. use a "lock" file

The fact that my application can potentially  have other problems with 
multiple instances, I implemented b)

The only thing I was wondering/surprised was that log4j blocked my 
application with the TelnetAppender. This should not happen because I 
can't know which ports on the client side are in use.

( Don't know if this belongs to the dev-list , just added it to complete 
the mail )

I had the following exception on startup :

java.net.BindException: Address in use: JVM_Bind
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:447)
        at java.net.ServerSocket.<init>(ServerSocket.java:165)
        at java.net.ServerSocket.<init>(ServerSocket.java:77)
        at 
org.apache.log4j.net.TelnetAppender$SocketHandler.<init>(TelnetAppender.java:172)
        at 
org.apache.log4j.net.TelnetAppender.activateOptions(TelnetAppender.java:62)
        at 
org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:248)
        at 
org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:124)
        at 
org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:88)
        at 
org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:645)
        at 
org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:603)
        at 
org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:500)
        at 
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:406)
        at 
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:307)
        at 
org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:315)
        at mgmtplatform.util.Trace.initLogFile(Trace.java:661)
        at mgmtplatform.util.Trace.<clinit>(Trace.java:638)
        at mgmtplatform.util.CheckLicense.init(CheckLicense.java:476)
        at mgmtplatform.util.CheckLicense.<init>(CheckLicense.java:109)
        at mgmtplatform.util.CheckLicense.instance(CheckLicense.java:92)
        at mgmtplatform.platform.ALMPlatform.main(ALMPlatform.java:175)

and this  when logging :

java.lang.NullPointerException
        at 
org.apache.log4j.net.TelnetAppender.append(TelnetAppender.java:89)
        at 
org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:222)
        at 
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:57)
        at org.apache.log4j.Category.callAppenders(Category.java:190)
        at org.apache.log4j.Category.forcedLog(Category.java:375)
        at org.apache.log4j.Category.error(Category.java:306)
        at mgmtplatform.util.Trace.log(Trace.java:146)
        at mgmtplatform.als.ALSCmdLoop.run(ALSCmdLoop.java:600)

As said I'm aware of the problem but it should not happen that the 
TelnetAppender blocks the application when the port is already in use.


Ceki, thanks for you're help !

Marc 



 

=============================================
Marc Herren
e-mail: [EMAIL PROTECTED]
Tel.:   ++41 31 999 39 15
Fax.:  ++41 31 999 30 57

ASCOM Transmission Ltd.
Carrier Access / GAAD
Belpstrasse 37
3000 Berne 14
Switzerland

http://www.ascom.ch 
http://www.broadnet.ascom.ch 


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

Reply via email to