Bug 50835 - NPE on AccessLogValve.getTimeZone
Summary: NPE on AccessLogValve.getTimeZone
Status: RESOLVED WORKSFORME
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 6.0.32
Hardware: Macintosh All
: P2 normal (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-26 10:03 UTC by based
Modified: 2011-02-26 11:48 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description based 2011-02-26 10:03:36 UTC
26 févr. 2011 15:43:54 org.apache.catalina.connector.CoyoteAdapter service
.lang.NullPointerException
	at org.apache.catalina.valves.AccessLogValve.getTimeZone(AccessLogValve.java:764)
	at org.apache.catalina.valves.AccessLogValve.access$800(AccessLogValve.java:122)
	at org.GRAVE: Une exception ou une erreur s'est produite dans le conteneur durant le traitement de la requête
javaapache.catalina.valves.AccessLogValve$DateAndTimeElement.addElement(AccessLogValve.java:1008)
	at org.apache.catalina.valves.AccessLogValve.log(AccessLogValve.java:575)
	at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1214)
	at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:562)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:296)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:680)


server.xml change:
   <Context path="/aa" docBase="aa" debug="true" reloadable="true" crossContext="true" >
            <Valve className="org.apache.catalina.valves.AccessLogValve"
         prefix="localhost_access_aa1_log." suffix=".txt"
         pattern="common"/>
         </Context>
Comment 1 Konstantin Kolinko 2011-02-26 11:04:19 UTC
I cannot reproduce it.

In what circumstances this was observed? Are there other errors and warnings or interesting messages in the logs? Did tomcat start successfully?



From the source, it can happen only of AccessLogValve#timezone is null, but that field is initialized in AccessLogValve#start().

Is it possible that the AccessLogValve#log() call happened before #start() was called? Maybe context itself failed to start and thus initialization did not complete?

(BTW, there should be at least one WARNING there, because there is no "debug" attribute in a Context.)
Comment 2 based 2011-02-26 11:41:40 UTC
I cannot reproduce it.

In what circumstances this was observed? Are there other errors and warnings or
interesting messages in the logs? Did tomcat start successfully?

> I tried to deployed a new apllication with H2 database inside.
I had problem with 
reloadable="true"and 
a catalina defined context for the same application:

aa.xml
<Context path="aa" reloadable="true" docBase="M/webapp" workDir="M/work" >
	<Logger className="org.apache.catalina.logger.SystemOutLogger" verbosity="4" timestamp="true"/>
	<Loader className="org.apache.catalina.loader.DevLoader" reloadable="true" debug="1" useSystemClassLoaderAsParent="false" />
</Context>


From the source, it can happen only of AccessLogValve#timezone is null, but
that field is initialized in AccessLogValve#start().

Is it possible that the AccessLogValve#log() call happened before #start() was
called? Maybe context itself failed to start and thus initialization did not
complete?



(BTW, there should be at least one WARNING there, because there is no "debug"
attribute in a Context.)

> Sorry, it was a configuration issue with the aa.xml in catalina/localhost folder, it is now working as expected.

You can close the issue, if you want.
Comment 3 Chuck Caldarale 2011-02-26 11:48:41 UTC
(In reply to comment #2)
> aa.xml
> <Context path="aa" reloadable="true" docBase="M/webapp" workDir="M/work" >
>     <Logger className="org.apache.catalina.logger.SystemOutLogger"
> verbosity="4" timestamp="true"/>
>     <Loader className="org.apache.catalina.loader.DevLoader" reloadable="true"
> debug="1" useSystemClassLoaderAsParent="false" />
> </Context>

You really need to spend some time with the current Tomcat documentation.  For example, the <Logger> element has not been used in many years.  You cannot blindly copy configuration settings from older versions of Tomcat into a newer one and expect anything close to reliable results.