<adding Ruchira & Sagara & dev group> Did you try the Before start event?
Sorry, If I misunderstood the last email. On Fri, Jun 13, 2014 at 11:13 AM, Mohamed Nasmin <[email protected]> wrote: > > Thanks once again. I tried that by configuring context.xml. But I cannot > trigger the BEFORE_INIT_EVENT. Other events are triggering well. This is > the out put after configuring the listener with context.xml. > > INFO: Deploying web application directory > /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/docs > > > *this is before start eventthis is start eventthis is after start event* > Jun 13, 2014 11:03:27 AM org.apache.catalina.startup.HostConfig > deployDirectory > INFO: Deployment of web application directory > /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/docs has finished in 1,482 > ms > Jun 13, 2014 11:03:27 AM org.apache.catalina.startup.HostConfig > deployDirectory > > INFO: Deploying web application directory > /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/manager > > > *this is before start eventthis is start eventthis is after start event* > Jun 13, 2014 11:03:28 AM org.apache.catalina.startup.HostConfig > deployDirectory > INFO: Deployment of web application directory > /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/manager has finished in > 211 ms > Jun 13, 2014 11:03:28 AM org.apache.catalina.startup.HostConfig > deployDirectory > > INFO: Deploying web application directory > /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/host-manager > > > *this is before start event this is start eventthis is after start event* > Jun 13, 2014 11:03:28 AM org.apache.catalina.startup.HostConfig > deployDirectory > INFO: Deployment of web application directory > /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/host-manager has finished > in 208 ms > Jun 13, 2014 11:03:28 AM org.apache.catalina.startup.HostConfig > deployDirectory > > INFO: Deploying web application directory > /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/ROOT > > > *this is before start eventthis is start event this is after start event* > Jun 13, 2014 11:03:28 AM org.apache.catalina.startup.HostConfig > deployDirectory > INFO: Deployment of web application directory > /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/ROOT has finished in 105 ms > Jun 13, 2014 11:03:28 AM org.apache.catalina.startup.HostConfig > deployDirectory > > INFO: Deploying web application directory > /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/examples > > > *this is before start eventthis is start event this is after start event* > Jun 13, 2014 11:03:29 AM org.apache.catalina.startup.HostConfig > deployDirectory > INFO: Deployment of web application directory > /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/examples has finished in > 1,136 ms > Jun 13, 2014 11:03:29 AM org.apache.coyote.AbstractProtocol start > INFO: Starting ProtocolHandler ["http-bio-8080"] > Jun 13, 2014 11:03:29 AM org.apache.coyote.AbstractProtocol start > INFO: Starting ProtocolHandler ["ajp-bio-8009"] > Jun 13, 2014 11:03:29 AM org.apache.catalina.startup.Catalina start > INFO: Server startup in 4090 ms > > In the context.xml I put like below. But there is a WatchedResource > element. It already run and initialize the context. I googled it but could > not find a solution. Can we handle this issue? If we get triggered > BEFORE_INIT_EVENT here then my problem is solved. Please advice on this. > Thanks alot for your guidance ayye. > > <!-- Default set of monitored resources --> > <Listener className="org.jaggery.tomcat.listener.TomcatListener" /> > *<WatchedResource>WEB-INF/web.xml</WatchedResource>* > > > > On Fri, Jun 13, 2014 at 10:52 AM, Chamil Jeewantha <[email protected]> > wrote: > >> Please try configuring your lifecycle listener on context.xml file. [1]. >> >> [1] http://tomcat.apache.org/tomcat-5.5-doc/config/context.html >> >> >> On Fri, Jun 13, 2014 at 12:29 AM, Mohamed Nasmin <[email protected]> >> wrote: >> >>> Thanks for the reply Ayye. >>> >>> This is the code I checked. >>> >>> public void lifecycleEvent(LifecycleEvent event) { >>> >>> String type = event.getType(); >>> if (Lifecycle.BEFORE_INIT_EVENT.equals(type)) { >>> >>> System.out.println("this is before init event"); >>> >>> //Object source = event.getSource(); >>> Lifecycle source = event.getLifecycle(); >>> >>> if (source instanceof StandardContext) { >>> >>> System.out.println("it is a Context nested lifecycle event"); >>> StandardContext standardContext = (StandardContext) source; >>> System.out.println("Context details : " + >>> standardContext.toString()); >>> } >>> else{ >>> System.out.println("There is no app source available"); >>> } >>> >>> } >>> else if (Lifecycle.BEFORE_START_EVENT.equals(type)){ >>> System.out.println("this is before start event"); >>> } >>> else if (Lifecycle.AFTER_INIT_EVENT.equals(type)){ >>> System.out.println("this is after init event"); >>> } >>> else if (Lifecycle.AFTER_START_EVENT.equals(type)){ >>> System.out.println("this is after start event"); >>> } >>> else if (Lifecycle.BEFORE_STOP_EVENT.equals(type)){ >>> System.out.println("this is before stop event"); >>> } >>> else if (Lifecycle.BEFORE_DESTROY_EVENT.equals(type)){ >>> System.out.println("this is before destroy event"); >>> } >>> else if (Lifecycle.AFTER_STOP_EVENT.equals(type)){ >>> System.out.println("this is after stop event"); >>> } >>> else if (Lifecycle.AFTER_DESTROY_EVENT.equals(type)){ >>> System.out.println("this is after destroy event"); >>> } >>> else if (Lifecycle.START_EVENT.equals(type)){ >>> System.out.println("this is start event"); >>> } >>> else if (Lifecycle.STOP_EVENT.equals(type)){ >>> System.out.println("this is stop event"); >>> } >>> else if (Lifecycle.PERIODIC_EVENT.equals(type)){ >>> System.out.println("this is periodic event"); >>> } >>> } >>> >>> Terminal Output : >>> >>> Listening for transport dt_socket at address: 8000 >>> Jun 13, 2014 12:23:22 AM org.apache.catalina.core.AprLifecycleListener >>> init >>> INFO: The APR based Apache Tomcat Native library which allows optimal >>> performance in production environments was not found on the >>> java.library.path: /usr/java/packages/lib/i386:/lib:/usr/lib >>> >>> *this is before init eventThere is no app source available* >>> Jun 13, 2014 12:23:23 AM org.apache.coyote.AbstractProtocol init >>> INFO: Initializing ProtocolHandler ["http-bio-8080"] >>> Jun 13, 2014 12:23:23 AM org.apache.coyote.AbstractProtocol init >>> INFO: Initializing ProtocolHandler ["ajp-bio-8009"] >>> *this is after init event* >>> Jun 13, 2014 12:23:23 AM org.apache.catalina.startup.Catalina load >>> INFO: Initialization processed in 2514 ms >>> >>> *this is before start event this is start event* >>> Jun 13, 2014 12:23:23 AM org.apache.catalina.core.StandardService >>> startInternal >>> INFO: Starting service Catalina >>> Jun 13, 2014 12:23:23 AM org.apache.catalina.core.StandardEngine >>> startInternal >>> INFO: Starting Servlet Engine: Apache Tomcat/7.0.54 >>> Jun 13, 2014 12:23:23 AM org.apache.catalina.startup.HostConfig >>> deployDirectory >>> INFO: Deploying web application directory >>> /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/docs >>> Jun 13, 2014 12:23:25 AM org.apache.catalina.util.SessionIdGenerator >>> createSecureRandom >>> INFO: Creation of SecureRandom instance for session ID generation using >>> [SHA1PRNG] took [214] milliseconds. >>> Jun 13, 2014 12:23:25 AM org.apache.catalina.startup.HostConfig >>> deployDirectory >>> INFO: Deployment of web application directory >>> /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/docs has finished in 1,667 >>> ms >>> Jun 13, 2014 12:23:25 AM org.apache.catalina.startup.HostConfig >>> deployDirectory >>> INFO: Deploying web application directory >>> /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/manager >>> Jun 13, 2014 12:23:25 AM org.apache.catalina.startup.HostConfig >>> deployDirectory >>> INFO: Deployment of web application directory >>> /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/manager has finished in >>> 251 ms >>> Jun 13, 2014 12:23:25 AM org.apache.catalina.startup.HostConfig >>> deployDirectory >>> INFO: Deploying web application directory >>> /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/host-manager >>> Jun 13, 2014 12:23:25 AM org.apache.catalina.startup.HostConfig >>> deployDirectory >>> INFO: Deployment of web application directory >>> /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/host-manager has finished >>> in 213 ms >>> Jun 13, 2014 12:23:25 AM org.apache.catalina.startup.HostConfig >>> deployDirectory >>> INFO: Deploying web application directory >>> /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/ROOT >>> Jun 13, 2014 12:23:26 AM org.apache.catalina.startup.HostConfig >>> deployDirectory >>> INFO: Deployment of web application directory >>> /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/ROOT has finished in 157 ms >>> Jun 13, 2014 12:23:26 AM org.apache.catalina.startup.HostConfig >>> deployDirectory >>> INFO: Deploying web application directory >>> /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/examples >>> Jun 13, 2014 12:23:27 AM org.apache.catalina.startup.HostConfig >>> deployDirectory >>> INFO: Deployment of web application directory >>> /home/nasmin/tomcat/apache-tomcat-7.0.54/webapps/examples has finished in >>> 1,449 ms >>> Jun 13, 2014 12:23:27 AM org.apache.coyote.AbstractProtocol start >>> INFO: Starting ProtocolHandler ["http-bio-8080"] >>> Jun 13, 2014 12:23:27 AM org.apache.coyote.AbstractProtocol start >>> INFO: Starting ProtocolHandler ["ajp-bio-8009"] >>> *this is after start event* >>> Jun 13, 2014 12:23:27 AM org.apache.catalina.startup.Catalina start >>> INFO: Server startup in 3991 ms >>> >>> >>> Please check the highlighted output. It triggers the event on server >>> init & start. But we need to get the event before context init. Thanks >>> again for the reply. Please advice on this. >>> >>> >>> >>> >>> >>> >>> On Fri, Jun 13, 2014 at 12:13 AM, Chamil Jeewantha <[email protected]> >>> wrote: >>> >>>> Hi >>>> >>>> Could you please share your code here. >>>> >>>> Regards, >>>> Chamil >>>> >>>> >>>> On Thu, Jun 12, 2014 at 10:56 PM, Mohamed Nasmin <[email protected]> >>>> wrote: >>>> >>>>> Hi Ayye, >>>>> >>>>> I created the lifecycle listener like above mentioned link and test >>>>> the output by debugging the tomcat. But it captured the events related to >>>>> the server. For example BEFORE_INIT_EVENT triggers before initializing the >>>>> tomcat server. >>>>> >>>>> Here our requirement is we need to have BEFORE_INIT_EVENT for each >>>>> context in the tomcat. Is there any way to have this? Our task is, before >>>>> initializing the context (not the server) we need to check whether app is >>>>> jaggery app or other app. >>>>> >>>>> Thanks. >>>>> >>>>> >>>>> On Wed, Jun 11, 2014 at 6:07 PM, Mohamed Nasmin <[email protected]> >>>>> wrote: >>>>> >>>>>> Thanks alot for your assistance ayye :) >>>>>> >>>>>> >>>>>> On Wed, Jun 11, 2014 at 1:29 PM, Chamil Jeewantha <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> Hi Nasmin, >>>>>>> >>>>>>> You can use [1] as a example of a Tomcat Lifecycle listener. >>>>>>> >>>>>>> [1] >>>>>>> https://github.com/kdchamil/ASTomEE/blob/master/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ServerListener.java >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> K.D. Chamil Jeewantha >>>>>>> Associate Technical Lead >>>>>>> WSO2, Inc.; http://wso2.com >>>>>>> Mobile: +94716813892 >>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>>> >>>> -- >>>> K.D. Chamil Jeewantha >>>> Associate Technical Lead >>>> WSO2, Inc.; http://wso2.com >>>> Mobile: +94716813892 >>>> >>>> >>> >> >> >> -- >> K.D. Chamil Jeewantha >> Associate Technical Lead >> WSO2, Inc.; http://wso2.com >> Mobile: +94716813892 >> >> > -- K.D. Chamil Jeewantha Associate Technical Lead WSO2, Inc.; http://wso2.com Mobile: +94716813892
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
