axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bethana kumar <bethana_ku...@yahoo.com>
Subject stop app server to load other resources when initservlet fails
Date Fri, 15 Oct 2004 17:13:31 GMT

Hi

I have a requirement is that i have a initservlet which loads initially when jboss(tomcat)
starts up,which check all initial resources(i.e db is up or not),if any resources are not
properly startup which should display an error message that

system is not up and also it should not allow user work on this site(i.e index.jsp should
not be displayed)

 

 

I have added following entry in web.xml

 

 

<servlet>

<servlet-name>InitServlet</servlet-name>

<servlet-class>com.dol.mi.servlet.InitServlet</servlet-class>

<load-on-startup>0</load-on-startup>

</servlet> 

 

 

This is myservlet

 

public class InitServlet extends HttpServlet 

{

/**

* Logger for this class

*/

private static final Logger logger = Logger.getLogger(InitServlet.class);

Reminder rm=null;

/**

* Constructor of the object.

*/

public InitServlet() {

super();

}

/**

* Destruction of the servlet. <br>

*/

public void destroy() {

if (logger.isDebugEnabled()) {

logger.debug("destroy() - start");

}

super.destroy(); // Just puts "destroy" string in log

if(this.rm!=null)

this.rm.stopReminder();

if (logger.isDebugEnabled()) {

logger.debug("destroy() - end");

}

}

 

/**

* Initialization of the servlet. <br>

*

* @throws ServletException if an error occure

*/

public void init() throws ServletException {

if (logger.isDebugEnabled()) {

logger.debug("init() - start");

}

try{

System.out.print("InitServletttttttt");

rm=new Reminder();

rm.startReminder();

SMSFile.validateDirectory(new File(SMSConstants.SMS_SERVER_DIRECTORY));

ResourceManager.checkDatabaseExistOrNot();



}

catch(ReminderException ex)

{

if (logger.isEnabledFor(org.apache.log4j.Priority.ERROR)) {

logger.error("init()", ex);

}

ex.printStackTrace();

throw new ServletException(ex);

}

catch(SMSException smex)

{

if (logger.isEnabledFor(org.apache.log4j.Priority.ERROR)) {

logger.error("init()", smex);

}

smex.printStackTrace();

throw new ServletException(smex);

}

catch(ClassNotFoundException cex)

{

if (logger.isEnabledFor(org.apache.log4j.Priority.ERROR)) {

logger.error("init()", cex);

}

cex.printStackTrace();

throw new ServletException(cex);

}

if (logger.isDebugEnabled()) {

logger.debug("init() - end");

}

}

}


		
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!
Mime
View raw message