Re: hotdeploy of war files results in static variable being null

2008-07-23 Thread Felix Gnass

Hi,

as far as I know Tomcat's WebappClassloader sets final static references 
to null upon re-deployments to prevent memory leaks. The following page 
describes what's happening: 
http://wiki.apache.org/jakarta-commons/Logging/StaticLog


One possible solution would be not to use static loggers.

Best regards,
-Felix


Fu-Tung Cheng wrote:

Hi,

I sometime hotdeploy my war file to tomcat 6.0.16.  I have noticed that a 
static variable in one of my classes then ends up being null.

The variable is initialized as follows:

private static Logger logger = Logger.getLogger(MyClass.class);

and then used below in a method:

public void mymethod(String mystring) {
  logger.info(mystring + " did something");
}   

This is a little annoying as I then need to restart the server for this class to work properly.  


Is this a known bug?  I could probably create a little sample war file to 
demonstrate the issue but I don't want to go through that if you guys already 
know about the issue.

Thanks,

Fu-Tung


  



-
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]



Re: hotdeploy of war files results in static variable being null

2008-07-23 Thread Felix Gnass
Talking about loggers and NullPointerExceptions ... I get the following 
stacktrace every time an application is re-deployed:


log4j:ERROR LogMananger.repositorySelector was null likely due to error 
in class reloading, using NOPLoggerRepository.
Jul 23, 2008 4:31:47 PM org.apache.catalina.core.StandardContext 
processTlds

SEVERE: Error reading tld listeners java.lang.NullPointerException
java.lang.NullPointerException
  at org.apache.log4j.Category.isEnabledFor(Category.java:749)
  at 
org.apache.commons.logging.impl.Log4JLogger.isTraceEnabled(Log4JLogger.java:333) 

  at 
org.apache.catalina.startup.TldConfig.tldScanResourcePaths(TldConfig.java:581) 


  at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:282)
  at 
org.apache.catalina.core.StandardContext.processTlds(StandardContext.java:4307) 

  at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4144)
  at 
org.apache.catalina.core.StandardContext.reload(StandardContext.java:3025)
  at 
org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:432) 

  at 
org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1278) 

  at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1570) 

  at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579) 

  at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579) 

  at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1559) 


  at java.lang.Thread.run(Thread.java:595)


I'm using Tomcat 5.5.25 (inside Eclipse) and the application uses 
commons-logging + Log4j itself, therefore both jars are loaded from 
WEB-INF/lib. Can anybody explain what's happening here and who's to 
blame for this error?


Thanks a lot,
-Felix


Felix Gnass wrote:

Hi,

as far as I know Tomcat's WebappClassloader sets final static 
references to null upon re-deployments to prevent memory leaks. The 
following page describes what's happening: 
http://wiki.apache.org/jakarta-commons/Logging/StaticLog


One possible solution would be not to use static loggers.

Best regards,
-Felix


Fu-Tung Cheng wrote:

Hi,

I sometime hotdeploy my war file to tomcat 6.0.16.  I have noticed 
that a static variable in one of my classes then ends up being null.


The variable is initialized as follows:

private static Logger logger = Logger.getLogger(MyClass.class);

and then used below in a method:

public void mymethod(String mystring) {
  logger.info(mystring + " did something");
}   

This is a little annoying as I then need to restart the server for 
this class to work properly. 
Is this a known bug?  I could probably create a little sample war 
file to demonstrate the issue but I don't want to go through that if 
you guys already know about the issue.


Thanks,

Fu-Tung


 


-
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]




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