You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Manuri Amaya Perera <am...@gmail.com> on 2015/07/19 08:26:09 UTC
Tomcat 7.0.34 - Lifecycle listener is not catching the events before
the before_start vent
Hi,
I am using tomcat 7.0.34. I've written a simple Lifecycle listener
implementing org.apache.catalina.LifecycleListener.
I am simply overriding the lifecycleEvent method and printing the event
type. When a web application is being deployed, the first event I can see
is before_start.
But there should be several events before that such as before_init.
Is this the expected behavior?
Thank you.
--
*Regards*
*Manuri Amaya Perera,*
*Undergraduate,*
*Department of Computer Science & Engineering,*
*University of Moratuwa,*
*Sri Lanka.*
Re: Tomcat 7.0.34 - Lifecycle listener is not catching the events
before the before_start vent
Posted by Manuri Amaya Perera <am...@gmail.com>.
Thank you Konstantin.
On Sun, Jul 19, 2015 at 6:29 PM, Konstantin Kolinko <kn...@gmail.com>
wrote:
> 2015-07-19 9:26 GMT+03:00 Manuri Amaya Perera <am...@gmail.com>:
> > Hi,
> >
> > I am using tomcat 7.0.34. I've written a simple Lifecycle listener
> > implementing org.apache.catalina.LifecycleListener.
> >
> > I am simply overriding the lifecycleEvent method and printing the event
> > type. When a web application is being deployed, the first event I can see
> > is before_start.
> > But there should be several events before that such as before_init.
> >
> > Is this the expected behavior?
>
> Reproducible with the current 7.0.63.
>
> This is an expected behaviour. Context itself is configured by a listener.
>
> The listeners are added by
> org.apache.catalina.startup.ContextConfig#processContextConfig() -
> parses context.xml files (the global ones and the one for the web
> application)
> - called from o.a.c.startup.ContextConfig#contextConfig()
> - called from o.a.c.startup.ContextConfig#init()
> - called from o.a.c.startup.lifecycleEvent() on Lifecycle.AFTER_INIT_EVENT
>
> At the time of the "after_init" event the "before_init" event has
> already happened.
>
>
> For reference, reproduction source code
> a sample listener class, to be put into catalina.base/lib/test
> [[[
> package test;
>
> import org.apache.catalina.LifecycleEvent;
> import org.apache.catalina.LifecycleListener;
> import org.apache.juli.logging.Log;
> import org.apache.juli.logging.LogFactory;
>
> public class TestListener implements LifecycleListener {
> private final Log log = LogFactory.getLog(getClass());
> @Override
> public void lifecycleEvent(LifecycleEvent event) {
> log.info("Event: [" + event.getType() + "]");
> }
> }
> ]]]
>
> configuration, catalina.base/webapps/examples/META-INF/context.xml
> [[[
> <Context>
> <Listener className="test.TestListener" />
> </Context>
> ]]]
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
*Regards*
*Manuri Amaya Perera,*
*Undergraduate,*
*Department of Computer Science & Engineering,*
*University of Moratuwa,*
*Sri Lanka.*
Re: Tomcat 7.0.34 - Lifecycle listener is not catching the events
before the before_start vent
Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-07-19 9:26 GMT+03:00 Manuri Amaya Perera <am...@gmail.com>:
> Hi,
>
> I am using tomcat 7.0.34. I've written a simple Lifecycle listener
> implementing org.apache.catalina.LifecycleListener.
>
> I am simply overriding the lifecycleEvent method and printing the event
> type. When a web application is being deployed, the first event I can see
> is before_start.
> But there should be several events before that such as before_init.
>
> Is this the expected behavior?
Reproducible with the current 7.0.63.
This is an expected behaviour. Context itself is configured by a listener.
The listeners are added by
org.apache.catalina.startup.ContextConfig#processContextConfig() -
parses context.xml files (the global ones and the one for the web
application)
- called from o.a.c.startup.ContextConfig#contextConfig()
- called from o.a.c.startup.ContextConfig#init()
- called from o.a.c.startup.lifecycleEvent() on Lifecycle.AFTER_INIT_EVENT
At the time of the "after_init" event the "before_init" event has
already happened.
For reference, reproduction source code
a sample listener class, to be put into catalina.base/lib/test
[[[
package test;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
public class TestListener implements LifecycleListener {
private final Log log = LogFactory.getLog(getClass());
@Override
public void lifecycleEvent(LifecycleEvent event) {
log.info("Event: [" + event.getType() + "]");
}
}
]]]
configuration, catalina.base/webapps/examples/META-INF/context.xml
[[[
<Context>
<Listener className="test.TestListener" />
</Context>
]]]
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org