You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Justin Randall <ra...@hotmail.com> on 2008/12/04 01:22:15 UTC
Tomcat 6.0.18 Servlet Loading/Reloading
Hello,
I have a very strange issue with Tomcat 6.0.18 and I'm not sure what information to provide to help debug further.
I have an installation of Tomcat 6.0.18 which fails to properly initialize servlets upon restart. If I deploy a new application.war file while Tomcat is running (even if it is the same war file with different modify timestamp) everything loads up just fine. Below are the system details:
- Tomcat: Tomcat version 6.0.18 with APR 1.1.14
- Java: JDK 1.6u10
- RedHat Enteprise Linux 5
It seems that Servlet X, for example, does load to a point, because it returns a value, however the log4j subsystem is not initialized at all (providing me with no debug info at all) and catalina.out/err show no signs of trouble. Below is a snippet of restarting Tomcat.
=====
Dec 3, 2008 7:08:36 PM org.apache.coyote.http11.Http11AprProtocol pause
INFO: Pausing Coyote HTTP/1.1 on http-80
Dec 3, 2008 7:08:37 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Dec 3, 2008 7:08:37 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Dec 3, 2008 7:08:37 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Dec 3, 2008 7:08:37 PM org.apache.coyote.http11.Http11AprProtocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-80
Dec 3, 2008 7:08:43 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.14.
Dec 3, 2008 7:08:43 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Dec 3, 2008 7:08:43 PM org.apache.coyote.http11.Http11AprProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-80
Dec 3, 2008 7:08:43 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 562 ms
Dec 3, 2008 7:08:43 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Dec 3, 2008 7:08:43 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
Dec 3, 2008 7:08:44 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Dec 3, 2008 7:08:44 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Dec 3, 2008 7:08:44 PM org.apache.coyote.http11.Http11AprProtocol start
INFO: Starting Coyote HTTP/1.1 on http-80
Dec 3, 2008 7:08:44 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1432 ms
AbandonedObjectPool is used (org.apache.tomcat.dbcp.dbcp.AbandonedObjectPool@10f102d3)
LogAbandoned: false
RemoveAbandoned: true
RemoveAbandonedTimeout: 60
=====
Then once I move a new .war file into the webapps directory:
=====
Dec 3, 2008 7:20:25 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/thewebapplication]
Dec 3, 2008 7:20:25 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive thewebapplication.war
=====
Has anyone else ever experienced this before and can provide some help?
Kind regards,
Justin
_________________________________________________________________
RE: Tomcat 6.0.18 Servlet Loading/Reloading
Posted by Justin Randall <ra...@hotmail.com>.
Hello,
After continuing to dig further and perform some additional debugging, it turns out that the "init" methods are being called on startup.
The problem is that the DataSource which I'm pulling from the ServletContext is failing to initialize itself on start-up, but succeeds when moving the .war file into the webapps directory. I'll continue to debug this further and respond with more information as it becomes available.
Thanks,
Justin.
> From: randju@hotmail.com
> To: users@tomcat.apache.org
> Subject: RE: Tomcat 6.0.18 Servlet Loading/Reloading
> Date: Thu, 4 Dec 2008 10:00:38 -0500
>
>
> Hi Chuck,
>
> Thanks for the response. I guess perhaps I was not clear enough in my configuration or description of the issue.
>
> Each Servlet in the application has <load-on-startup>X</load-on-startup> where X represents the numeric order in which I've assigned them to start.
>
> Also what I did mention previously is that "init" is NOT called when I browse to the URI, however the Servlet is loaded as my System.out.println statements in "doGet/doPost" are being output to catalina.out and they also show that "init" was never called (by checking parameters that should have been initialized by "init".
>
> Lastly, the reason I say "init' methods is that there IS more than one, and Tomcat calls both of them when initializing a Servlet. If you think this is incorrect, make sure to @Override both "init" and "init(ServletConfig config)" and have different logging statements. You will see both of them being executed when Tomcat loads the Servlet.
>
> I hope this helps better clarify the situation.
>
> Justin.
>
> > From: Chuck.Caldarale@unisys.com
> > To: users@tomcat.apache.org
> > Date: Wed, 3 Dec 2008 20:46:50 -0600
> > Subject: RE: Tomcat 6.0.18 Servlet Loading/Reloading
> >
> > > From: Justin Randall [mailto:randju@hotmail.com]
> > > Subject: RE: Tomcat 6.0.18 Servlet Loading/Reloading
> > >
> > > Basically when I restart Tomcat, it doesn't call any of the
> > > "init" methods of the Servlet
> >
> > Unless you have <load-on-startup> set for the servlet in your webapp's WEB-INF/web.xml, that is correct behavior for a Tomcat restart. The init() method (there can only be one per servlet) should be called upon first reference to a URL that matches a <url-pattern> element inside one of your <servlet-mapping> elements. If <load-on-startup> is set, the init() method will be called at Tomcat restart for each such servlet.
> >
> > > however all of the initialization which was to be
> > > performed by the "init" methods was never done.
> >
> > You keep using the word "methods" when there is only one init() method for a given servlet; why is that?
> >
> > > When I copy the existing war file from the webapps directory
> > > to another location, update the modify timestamp and then
> > > move it back into the webapps directory, the "init" methods
> > > are then called and the application works properly.
> >
> > This is also correct behavior for initial or re-deployment. Although the spec doesn't require it, Tomcat calls the init() methods to verify webapp viability at these times.
> >
> > - Chuck
> >
> >
> > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
>
> _________________________________________________________________
>
_________________________________________________________________
RE: Tomcat 6.0.18 Servlet Loading/Reloading
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Subject: Re: Tomcat 6.0.18 Servlet Loading/Reloading
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> It's also a good idea to call this.init() as well, since that's the
> expected behavior established by GenericServlet.
Or just do it the preferred way, which is override only the plain init() method and not the one with the parameter. The whole point of providing a convenience method (which is what init() is documented to be) is that it's convenient to use...
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat 6.0.18 Servlet Loading/Reloading
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Chris,
Chris Hut wrote:
> If you override: public void init(ServletConfig config), you MUST call
> super.init(config). If you don't, the config member of the base servlet
> class won't get set, which could cause problems downstream.
It's also a good idea to call this.init() as well, since that's the
expected behavior established by GenericServlet.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkk4VGkACgkQ9CaO5/Lv0PBMIgCgnkfD/IRhhbadyzMBw1NwRmH9
3wUAniuuSdjf6wYeZeA/3dSS+nUJV2iZ
=4dC2
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Tomcat 6.0.18 Servlet Loading/Reloading
Posted by Chris Hut <ch...@onetruemedia.com>.
Re: init() methods, not knowing if this is the cause of the errant
behavior but FYI just in case:
Per the API documentation:
http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html
If you override: public void init(ServletConfig config), you MUST call
super.init(config). If you don't, the config member of the base servlet
class won't get set, which could cause problems downstream.
public void init() - no parameters - is intended to be a convenience
method that you can override and not have to remember to call
super.init(). It is invoked by GenericServlet.init(ServletConfig).
Chris
-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: Thursday, December 04, 2008 7:22 AM
To: Tomcat Users List
Subject: RE: Tomcat 6.0.18 Servlet Loading/Reloading
> From: Justin Randall [mailto:randju@hotmail.com]
> Subject: RE: Tomcat 6.0.18 Servlet Loading/Reloading
>
> Each Servlet in the application has
> <load-on-startup>X</load-on-startup> where X represents the
> numeric order in which I've assigned them to start.
Then yes, there's a problem, since your servlets should have been
initialized upon restart.
> Lastly, the reason I say "init' methods is that there
> IS more than one, and Tomcat calls both of them when
> initializing a Servlet.
Strictly speaking, that's true, but the parameterless one is intended to
be called by the other. There's no need to override both methods, and
I'm not sure what happens when you do. The normal implementation is
just to override init(), and let GenericServlet.init(ServletConfig) call
that one.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
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
RE: Tomcat 6.0.18 Servlet Loading/Reloading
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Justin Randall [mailto:randju@hotmail.com]
> Subject: RE: Tomcat 6.0.18 Servlet Loading/Reloading
>
> Each Servlet in the application has
> <load-on-startup>X</load-on-startup> where X represents the
> numeric order in which I've assigned them to start.
Then yes, there's a problem, since your servlets should have been initialized upon restart.
> Lastly, the reason I say "init' methods is that there
> IS more than one, and Tomcat calls both of them when
> initializing a Servlet.
Strictly speaking, that's true, but the parameterless one is intended to be called by the other. There's no need to override both methods, and I'm not sure what happens when you do. The normal implementation is just to override init(), and let GenericServlet.init(ServletConfig) call that one.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Tomcat 6.0.18 Servlet Loading/Reloading
Posted by Justin Randall <ra...@hotmail.com>.
Hi Chuck,
Thanks for the response. I guess perhaps I was not clear enough in my configuration or description of the issue.
Each Servlet in the application has <load-on-startup>X</load-on-startup> where X represents the numeric order in which I've assigned them to start.
Also what I did mention previously is that "init" is NOT called when I browse to the URI, however the Servlet is loaded as my System.out.println statements in "doGet/doPost" are being output to catalina.out and they also show that "init" was never called (by checking parameters that should have been initialized by "init".
Lastly, the reason I say "init' methods is that there IS more than one, and Tomcat calls both of them when initializing a Servlet. If you think this is incorrect, make sure to @Override both "init" and "init(ServletConfig config)" and have different logging statements. You will see both of them being executed when Tomcat loads the Servlet.
I hope this helps better clarify the situation.
Justin.
> From: Chuck.Caldarale@unisys.com
> To: users@tomcat.apache.org
> Date: Wed, 3 Dec 2008 20:46:50 -0600
> Subject: RE: Tomcat 6.0.18 Servlet Loading/Reloading
>
> > From: Justin Randall [mailto:randju@hotmail.com]
> > Subject: RE: Tomcat 6.0.18 Servlet Loading/Reloading
> >
> > Basically when I restart Tomcat, it doesn't call any of the
> > "init" methods of the Servlet
>
> Unless you have <load-on-startup> set for the servlet in your webapp's WEB-INF/web.xml, that is correct behavior for a Tomcat restart. The init() method (there can only be one per servlet) should be called upon first reference to a URL that matches a <url-pattern> element inside one of your <servlet-mapping> elements. If <load-on-startup> is set, the init() method will be called at Tomcat restart for each such servlet.
>
> > however all of the initialization which was to be
> > performed by the "init" methods was never done.
>
> You keep using the word "methods" when there is only one init() method for a given servlet; why is that?
>
> > When I copy the existing war file from the webapps directory
> > to another location, update the modify timestamp and then
> > move it back into the webapps directory, the "init" methods
> > are then called and the application works properly.
>
> This is also correct behavior for initial or re-deployment. Although the spec doesn't require it, Tomcat calls the init() methods to verify webapp viability at these times.
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
_________________________________________________________________
RE: Tomcat 6.0.18 Servlet Loading/Reloading
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Justin Randall [mailto:randju@hotmail.com]
> Subject: RE: Tomcat 6.0.18 Servlet Loading/Reloading
>
> Basically when I restart Tomcat, it doesn't call any of the
> "init" methods of the Servlet
Unless you have <load-on-startup> set for the servlet in your webapp's WEB-INF/web.xml, that is correct behavior for a Tomcat restart. The init() method (there can only be one per servlet) should be called upon first reference to a URL that matches a <url-pattern> element inside one of your <servlet-mapping> elements. If <load-on-startup> is set, the init() method will be called at Tomcat restart for each such servlet.
> however all of the initialization which was to be
> performed by the "init" methods was never done.
You keep using the word "methods" when there is only one init() method for a given servlet; why is that?
> When I copy the existing war file from the webapps directory
> to another location, update the modify timestamp and then
> move it back into the webapps directory, the "init" methods
> are then called and the application works properly.
This is also correct behavior for initial or re-deployment. Although the spec doesn't require it, Tomcat calls the init() methods to verify webapp viability at these times.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Tomcat 6.0.18 Servlet Loading/Reloading
Posted by Justin Randall <ra...@hotmail.com>.
I've been doing some more testing and added a bunch of "System.out.println" statements to the "init", "init(ServletConfig)", and "doPost/doGet" methods so that I could see what my application was doing without log4j initialized.
Basically when I restart Tomcat, it doesn't call any of the "init" methods of the Servlet, however it does load it partially. When I actually browse to the URL of the Servlet, I can see my "System.out.println" statements being output to catalina.out, however all of the initialization which was to be performed by the "init" methods was never done.
When I copy the existing war file from the webapps directory to another location, update the modify timestamp and then move it back into the webapps directory, the "init" methods are then called and the application works properly.
> From: randju@hotmail.com
> To: users@tomcat.apache.org
> Subject: Tomcat 6.0.18 Servlet Loading/Reloading
> Date: Wed, 3 Dec 2008 19:22:15 -0500
>
>
> Hello,
>
> I have a very strange issue with Tomcat 6.0.18 and I'm not sure what information to provide to help debug further.
>
> I have an installation of Tomcat 6.0.18 which fails to properly initialize servlets upon restart. If I deploy a new application.war file while Tomcat is running (even if it is the same war file with different modify timestamp) everything loads up just fine. Below are the system details:
>
> - Tomcat: Tomcat version 6.0.18 with APR 1.1.14
> - Java: JDK 1.6u10
> - RedHat Enteprise Linux 5
>
> It seems that Servlet X, for example, does load to a point, because it returns a value, however the log4j subsystem is not initialized at all (providing me with no debug info at all) and catalina.out/err show no signs of trouble. Below is a snippet of restarting Tomcat.
>
> =====
> Dec 3, 2008 7:08:36 PM org.apache.coyote.http11.Http11AprProtocol pause
> INFO: Pausing Coyote HTTP/1.1 on http-80
> Dec 3, 2008 7:08:37 PM org.apache.catalina.core.StandardService stop
> INFO: Stopping service Catalina
> Dec 3, 2008 7:08:37 PM org.apache.catalina.core.ApplicationContext log
> INFO: SessionListener: contextDestroyed()
> Dec 3, 2008 7:08:37 PM org.apache.catalina.core.ApplicationContext log
> INFO: ContextListener: contextDestroyed()
> Dec 3, 2008 7:08:37 PM org.apache.coyote.http11.Http11AprProtocol destroy
> INFO: Stopping Coyote HTTP/1.1 on http-80
> Dec 3, 2008 7:08:43 PM org.apache.catalina.core.AprLifecycleListener init
> INFO: Loaded APR based Apache Tomcat Native library 1.1.14.
> Dec 3, 2008 7:08:43 PM org.apache.catalina.core.AprLifecycleListener init
> INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
> Dec 3, 2008 7:08:43 PM org.apache.coyote.http11.Http11AprProtocol init
> INFO: Initializing Coyote HTTP/1.1 on http-80
> Dec 3, 2008 7:08:43 PM org.apache.catalina.startup.Catalina load
> INFO: Initialization processed in 562 ms
> Dec 3, 2008 7:08:43 PM org.apache.catalina.core.StandardService start
> INFO: Starting service Catalina
> Dec 3, 2008 7:08:43 PM org.apache.catalina.core.StandardEngine start
> INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
> Dec 3, 2008 7:08:44 PM org.apache.catalina.core.ApplicationContext log
> INFO: ContextListener: contextInitialized()
> Dec 3, 2008 7:08:44 PM org.apache.catalina.core.ApplicationContext log
> INFO: SessionListener: contextInitialized()
> Dec 3, 2008 7:08:44 PM org.apache.coyote.http11.Http11AprProtocol start
> INFO: Starting Coyote HTTP/1.1 on http-80
> Dec 3, 2008 7:08:44 PM org.apache.catalina.startup.Catalina start
> INFO: Server startup in 1432 ms
> AbandonedObjectPool is used (org.apache.tomcat.dbcp.dbcp.AbandonedObjectPool@10f102d3)
> LogAbandoned: false
> RemoveAbandoned: true
> RemoveAbandonedTimeout: 60
> =====
>
> Then once I move a new .war file into the webapps directory:
>
> =====
> Dec 3, 2008 7:20:25 PM org.apache.catalina.startup.HostConfig checkResources
> INFO: Undeploying context [/thewebapplication]
> Dec 3, 2008 7:20:25 PM org.apache.catalina.startup.HostConfig deployWAR
> INFO: Deploying web application archive thewebapplication.war
> =====
>
> Has anyone else ever experienced this before and can provide some help?
>
> Kind regards,
>
> Justin
>
> _________________________________________________________________
>
_________________________________________________________________