You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Leon Rosenberg <ro...@googlemail.com> on 2006/04/26 15:49:09 UTC

tomcat 5.5.16 does strange things with my log4j?

Hi,

I'm still in process of migrating my application from 5.0 to 5.5. One
of the still open issues is the shutdown behaviour of the tomcat.
Right now I see very strange exceptions in the log file after I call
shutdown.sh or hit ctrl-c in catalina.sh run:

I get null pointer exceptions in following code:

	static{
		log = Logger.getLogger(QueuedEventSender.class);
	}

	public void run(){
		
		try{
		  ....
		}catch(Throwable ttt){
				log.error("run ", ttt); <--- null pointer
                }
       }

had to surround it with try catch:
			try{
				log.error("run ", ttt);
			}catch(Exception e){
				System.err.println("Can't log!!!");
				ttt.printStackTrace();
			}

another location:

	private static Logger log;
	static {
		log = Logger.getLogger(TimerServiceImpl.class);
	}

	public void run() {
		running = true;
		while (running) {
                        ...
			long executionStart = System.currentTimeMillis();
                        ....
			long executionEnd = System.currentTimeMillis();
			int duration = (int)(executionEnd-executionStart);
			if (log.isDebugEnabled())<-- null pointer exception
				log.debug("Timer execution lasted: "+duration);
		}
	}

how can it be? It happens after/middle in the shutdown only. Can it be
that tomcat somehow explicitely destroy the log4j Logger references
via class loader?
Kind of silly thought, but I can't see any plausible explanation for
the exceptions.

Any thoughts, anyone?

tia
Leon

I'm using jdk1.5, 2.6.8 kernel, tomcat 5.5.16, log4j-1.2.8.jar

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat 5.5.16 does strange things with my log4j?

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
could you post the stack trace you get from the NPE

Leon Rosenberg wrote:
> Hi,
>
> I'm still in process of migrating my application from 5.0 to 5.5. One
> of the still open issues is the shutdown behaviour of the tomcat.
> Right now I see very strange exceptions in the log file after I call
> shutdown.sh or hit ctrl-c in catalina.sh run:
>
> I get null pointer exceptions in following code:
>
> 	static{
> 		log = Logger.getLogger(QueuedEventSender.class);
> 	}
>
> 	public void run(){
> 		
> 		try{
> 		  ....
> 		}catch(Throwable ttt){
> 				log.error("run ", ttt); <--- null pointer
>                 }
>        }
>
> had to surround it with try catch:
> 			try{
> 				log.error("run ", ttt);
> 			}catch(Exception e){
> 				System.err.println("Can't log!!!");
> 				ttt.printStackTrace();
> 			}
>
> another location:
>
> 	private static Logger log;
> 	static {
> 		log = Logger.getLogger(TimerServiceImpl.class);
> 	}
>
> 	public void run() {
> 		running = true;
> 		while (running) {
>                         ...
> 			long executionStart = System.currentTimeMillis();
>                         ....
> 			long executionEnd = System.currentTimeMillis();
> 			int duration = (int)(executionEnd-executionStart);
> 			if (log.isDebugEnabled())<-- null pointer exception
> 				log.debug("Timer execution lasted: "+duration);
> 		}
> 	}
>
> how can it be? It happens after/middle in the shutdown only. Can it be
> that tomcat somehow explicitely destroy the log4j Logger references
> via class loader?
> Kind of silly thought, but I can't see any plausible explanation for
> the exceptions.
>
> Any thoughts, anyone?
>
> tia
> Leon
>
> I'm using jdk1.5, 2.6.8 kernel, tomcat 5.5.16, log4j-1.2.8.jar
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org