You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Fenderbosch, Eric" <Er...@fedex.com> on 2005/02/11 18:27:35 UTC

Adding ServletContextListener causes web app to not deploy

I've got a small web app that's working just fine. As soon as I add a listener, it fails to deploy.

Here's the relevant part of web.xml:

<?xml version="1.0" encoding="UTF-8"?>
 
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>net.fender.bazaar.struts.BazaarMessageResources</param-value>
  </context-param>
  <listener>
    <listener-class>net.fender.bazaar.servlet.BazaarServletContextListener</listener-class>
  </listener>

And the VERY simple listener:

package net.fender.bazaar.servlet;
 
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
 
class BazaarServletContextListener implements ServletContextListener {
 
    private ServletContext context;
 
    public void contextDestroyed(ServletContextEvent event) {
        context = null;
    }
 
    public void contextInitialized(ServletContextEvent event) {
        context = event.getServletContext();
    }
}

And the server log:
INFO: Removing web application at context path /bazaar
Feb 11, 2005 11:16:37 AM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:C:\java\jakarta-tomcat-5.0.28\conf\Catalina\localhost\bazaar.xml
Feb 11, 2005 11:17:30 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Feb 11, 2005 11:17:30 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Feb 11, 2005 11:17:30 AM org.apache.catalina.core.StandardContext start
SEVERE: Context startup failed due to previous errors

I'm using Tomcat 5.0.28 and Sun JDK 1.4.2_06-b03.

Any ideas?
TIA 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Adding ServletContextListener causes web app to not deploy

Posted by Martin Grotzke <ma...@javakaffee.de>.
hi,

you should make the class public.

cheers,
martin



On Fri, 2005-02-11 at 12:27 -0500, Fenderbosch, Eric wrote:
> I've got a small web app that's working just fine. As soon as I add a listener, it fails to deploy.
> 
> Here's the relevant part of web.xml:
> 
> <?xml version="1.0" encoding="UTF-8"?>
>  
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
>   <context-param>
>     <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
>     <param-value>net.fender.bazaar.struts.BazaarMessageResources</param-value>
>   </context-param>
>   <listener>
>     <listener-class>net.fender.bazaar.servlet.BazaarServletContextListener</listener-class>
>   </listener>
> 
> And the VERY simple listener:
> 
> package net.fender.bazaar.servlet;
>  
> import javax.servlet.ServletContext;
> import javax.servlet.ServletContextEvent;
> import javax.servlet.ServletContextListener;
>  
> class BazaarServletContextListener implements ServletContextListener {
>  
>     private ServletContext context;
>  
>     public void contextDestroyed(ServletContextEvent event) {
>         context = null;
>     }
>  
>     public void contextInitialized(ServletContextEvent event) {
>         context = event.getServletContext();
>     }
> }
> 
> And the server log:
> INFO: Removing web application at context path /bazaar
> Feb 11, 2005 11:16:37 AM org.apache.catalina.core.StandardHostDeployer install
> INFO: Processing Context configuration file URL file:C:\java\jakarta-tomcat-5.0.28\conf\Catalina\localhost\bazaar.xml
> Feb 11, 2005 11:17:30 AM org.apache.catalina.core.StandardContext listenerStart
> SEVERE: Skipped installing application listeners due to previous error(s)
> Feb 11, 2005 11:17:30 AM org.apache.catalina.core.StandardContext start
> SEVERE: Error listenerStart
> Feb 11, 2005 11:17:30 AM org.apache.catalina.core.StandardContext start
> SEVERE: Context startup failed due to previous errors
> 
> I'm using Tomcat 5.0.28 and Sun JDK 1.4.2_06-b03.
> 
> Any ideas?
> TIA 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
-- 
Martin Grotzke
Hohenesch 38, 22765 Hamburg
Tel.      +49 (0) 40.39905668
Mobil     +49 (0) 170.9365656
E-Mail    martin.grotzke@javakaffee.de
Online    http://www.javakaffee.de