Please help me with Event LIstener
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   A_KM
Posted On:   Tuesday, June 11, 2002 02:52 AM

Hi! Can anybody tell me what is wrong with my Event LIstener class. package store; import javax.servlet.*; import java.util.logging.*; import java.util.Date; public final class GlobalListener implements ServletContextListener,java.io.Serializable { private ServletContext context=null; public void contextInitialized(ServletContextEvent ev) { context=ev.getServletContext(); Logger logger=Logger.getLogger("4samurai"); try{ FileHandler fh = new FileHandler("4samurai.log"); logger.addHandler(fh); logger.setLevel(Level.ALL); logger.info("4samurai application inited at "+new Dat   More>>

Hi!


Can anybody tell me what is wrong with my Event LIstener class.

			
package store;

import javax.servlet.*;
import java.util.logging.*;
import java.util.Date;
public final class GlobalListener implements ServletContextListener,java.io.Serializable
{
private ServletContext context=null;
public void contextInitialized(ServletContextEvent ev)
{
context=ev.getServletContext();
Logger logger=Logger.getLogger("4samurai");
try{
FileHandler fh = new FileHandler("4samurai.log");
logger.addHandler(fh);
logger.setLevel(Level.ALL);
logger.info("4samurai application inited at "+new Date());
context.setAttribute("logger",logger);

}catch(java.io.IOException e)
{
}

}

public void contextDestroyed(ServletContextEvent e)
{
context=e.getServletContext();
context.removeAttribute("logger");

}
}


It returns me Tomcat Error application is not currently available when I add it to the list of Listeners in a war-file, containing JSP pages.

It doesn't work even if I leave methods empty.
Thanx.

   <<Less

re: Michael Dean

Posted By:   A_KM  
Posted On:   Wednesday, June 12, 2002 05:53 AM

Thanx for advice.


Everything seems to be at right place:
listener class is in WEB-INFclassesstore
I use deploytool and sun's j2ee server. In deploytool I click 'add' at Event Listener tab and choose store.GlobalListener.
I tried to find localhost_log* file but none found.
Heeeelp.

Re: Please help me with Event LIstener

Posted By:   michael_dean  
Posted On:   Tuesday, June 11, 2002 08:05 AM

Your class is fine. Most likely, the servlet container is having a problem locating the class.



Is your compiled class in the correct place (/WEB-INF/classes/store/GlobalListener.class or in store/GlobalListener.class of a JAR which is in /WEB-INF/lib)? If you check in your server log (i.e. something like localhost_log.2002-06-11.txt), you'll probably see messages like:




2002-06-11 10:56:20 StandardContext[]: Error configuring application listener of class store.GlobalListener
java.lang.ClassNotFoundException: store.GlobalListener
... [lots of stack trace info] ...
2002-06-11 10:56:20 StandardContext[]: Skipped installing application listeners due to previous error(s)
2002-06-11 10:56:20 StandardContext[]: Context startup failed due to previous errors
About | Sitemap | Contact