You can put your initialization code in a ServletContextListener so it
is executed before any servlets are run.
--
Len

On 3/9/07, suchitha koneru <[EMAIL PROTECTED]> wrote:
Thank you so much for the response. The reason I am doing this is , because
, I am using the servlet to  start the Active MQ Broker. There are two web
apps which will connect to the broker. The broker has to start first before
any of the web apps. Hence I want to load the servlet which starts the
broker, before any of the webapps get initialized.

is there any other way I can make sure that the broker will start before any
of the web apps .
Iam using tomcat 5.5.20 and Java 1.5


On 3/8/07, suchitha koneru <[EMAIL PROTECTED]> wrote:
>
> Hello Tomcat Users ,
>                      I am facing a problem starting  a servlet from
> tomcat's web.xml . I am using Tomcat 5.5.20. The reason , I am placing
> this servlet in tomcat's web.xml instead of a web app is because I want ,
> this servlet to start before  tomcat loads any of the web application
> contexts. I have java 1.5  on my system
> The following is the code for the servlet.
>
> *
>
> public
> **class* ActiveMQBrokerServlet *extends* GenericServlet{
>
> BrokerService
> broker ;
>
> *public* *void* init(ServletConfig config)* **throws* ServletException* *{
>
>
> *try*{
>
> broker = *new* BrokerService();
>
> System.
> *out*.println("Starting ActiveMQ Broker Service...");
>
> 
broker.addConnector("tcp://localhost:61616?trace=true&wireFormat.maxInactivityDuration=-1"
> );
>
> broker.start();
>
> System.
> *out*.println("Active MQ Broker Started at local host port 61616" );
>
> }
> *catch*(Exception e){
>
> e.printStackTrace();
>
> }
>
>  }
>
>  *public* *void* destroy(){
>
> *try*{
>
> broker.stop();
>
> System.
> *out*.println("Active MQ Broker Stopped at localhost port 61616" );
>
> }
> *catch*(Exception e){
>
> *throw* *new* RuntimeException(e);
>
> }
>
> }
>
> *public* *void* service(ServletRequest req , ServletResponse resp){
>
> }
>
> }
>
> This servet is specified as follows in tomcat's conf/web.xml
>
> <servlet>
>         <servlet-name>activemqbroker</servlet-name>
>
>         <servlet-class>
>           com.cisco.cpnm.common.messaging.ActiveMQBrokerServlet
>         </servlet-class>
>
>         <load-on-startup>6</load-on-startup>
>  </servlet>
>
> For some reason , the servlet is not loaded , and I do not see any error
> messages.
>
> The servlet class file and the required jars are placed in
> Tomcat/common/lib.
>
> Please let me know, if Iam missing anything.
>
> thanks,
>
> Suchitha.
>
>
>
>
>
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to