tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: Problem Loading Servlet on Server startup
Date Fri, 13 Sep 2002 13:00:55 GMT
HI,
For starters, you should override the init() method with no args, as
that's provided for your convenience.  It gets call from the one with
the ServletConfig arg.

Then, instead of saving a reference to the ServletConfig passed to init,
get a new one in your destroy method: in destroy, just have
ServletContext sc = getServletConfig().getServletContext();

I hope that helps,

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: info@projektinter.net [mailto:info@projektinter.net]
>Sent: Friday, September 13, 2002 7:12 AM
>To: Tomcat Users List
>Subject: Problem Loading Servlet on Server startup
>
>Hi,
>
>below is my current web.xml listed.
>As the first Servlet I am loading the InitAppServlet. The init(cfg
>ServletConfig) Methode lookes like:
>
>   public void init(ServletConfig cfg) throws ServletException
>     {
>          this.cfg = cfg;
>          this.ctx = cfg.getServletContext();
>          //initApp();
>
>     }//init()
>
>When I startup the application I get an Exception form the destroy()
>methode of the InitAppServlet is thrown.
>You can see below the thrown Execption
>As a strange thing: it already used to work!
>
>Does anyone have an idea?
>
>I am using Tomcat 4.0.1 on a Linux SuSE 7.3 Box, JDK 1.3.1
>
>thanks, rainer
>
>#####################################
>Exception:
>
>Servlet InitAppServlet threw unload() exception
>javax.servlet.ServletException: Servlet.destroy() for servlet
>InitAppServlet threw exception
> at
>org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:10
20)
> at
>org.apache.catalina.core.StandardWrapper.stop(StandardWrapper.java:1193
)
> at
>org.apache.catalina.core.StandardContext.reload(StandardContext.java:23
81)
> at
>org.apache.catalina.servlets.ManagerServlet.reload(ManagerServlet.java:
448)
> at
>org.apache.catalina.servlets.ManagerServlet.doGet(ManagerServlet.java:2
81)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic
atio
>nFilterChain.java:247)
> at
>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
terC
>hain.java:193)
> at
>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal
ve.j
>ava:243)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>566)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.core.StandardContextValve.invoke(StandardContextVal
ve.j
>ava:201)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>566)
> at
>org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticato
rBas
>e.java:518)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>564)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.core.StandardContext.invoke(StandardContext.java:23
44)
> at
>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav
a:16
>4)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>566)
> at
>org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherV
alve
>.java:170)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>564)
> at
>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav
a:17
>0)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>564)
> at
>org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:46
2)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>564)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve
.jav
>a:163)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>566)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.
java
>:1011)
> at
>org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java
:110
>6)
> at java.lang.Thread.run(Thread.java:484)
>----- Root Cause -----
>java.lang.NullPointerException
> at
javax.servlet.GenericServlet.getServletContext(GenericServlet.java:205)
> at javax.servlet.GenericServlet.log(GenericServlet.java:300)
> at javax.servlet.GenericServlet.destroy(GenericServlet.java:122)
> at
>org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:10
11)
> at
>org.apache.catalina.core.StandardWrapper.stop(StandardWrapper.java:1193
)
> at
>org.apache.catalina.core.StandardContext.reload(StandardContext.java:23
81)
> at
>org.apache.catalina.servlets.ManagerServlet.reload(ManagerServlet.java:
448)
> at
>org.apache.catalina.servlets.ManagerServlet.doGet(ManagerServlet.java:2
81)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic
atio
>nFilterChain.java:247)
> at
>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
terC
>hain.java:193)
> at
>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal
ve.j
>ava:243)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>566)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.core.StandardContextValve.invoke(StandardContextVal
ve.j
>ava:201)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>566)
> at
>org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticato
rBas
>e.java:518)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>564)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.core.StandardContext.invoke(StandardContext.java:23
44)
> at
>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav
a:16
>4)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>566)
> at
>org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherV
alve
>.java:170)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>564)
> at
>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav
a:17
>0)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>564)
> at
>org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:46
2)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>564)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve
.jav
>a:163)
> at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.j
ava:
>566)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
472)
> at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.
java
>:1011)
> at
>org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java
:110
>6)
> at java.lang.Thread.run(Thread.java:484)
>
>###########################################################
>
>web.xml:
>
><?xml version="1.0" encoding="ISO-8859-1"?>
>
><!DOCTYPE web-app
>    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
>    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
>
><web-app>
>
> <context-param>
>  <param-name>mapserver_pfad</param-name>
>  <param-value>http://jspserver</param-value>
>  <!-- <param-value>http://development.projektinter.net/</param-value>
-->
>  <description>MapServer-Pfad</description>
> </context-param>
> <context-param>
>  <param-name>mapserver_cgi_pfad</param-name>
>  <param-value>/cgi-bin/mapserv</param-value>
>  <description>MapServer CGI Pfad</description>
> </context-param>
> <context-param>
>  <param-name>apache_pfad</param-name>
>  <param-value>%2Fusr%2Flocal%2Fhttpd%2Fhtdocs%2F</param-value>
>  <description>Pfad zum Apache Server unter dem sich das mapserver
>Verzichnis befindet</description>
> </context-param>
> <context-param>
>  <param-name>tomcat_pfad</param-name>
>  <param-value>%2Fusr%2Flib%2Fjakarta-tomcat-4.0.1%2F</param-value>
>  <description>Pfad des Tomcat Wurzelverzeichnis</description>
> </context-param>
> <context-param>
>  <param-name>application_name</param-name>
>  <param-value>wwa-m</param-value>
>  <description>Name der Application</description>
> </context-param>
>
>   <servlet>
>    <servlet-name>InitAppServlet</servlet-name>
>    <servlet-class>net.projektinter.wwam.util.InitAppServlet</servlet-
>class>
>    <init-param>
>      <param-name>fileName</param-name>
>      <param-value>system.out.println</param-value>
> </init-param>
> <init-param>
>   <param-name>logLevel</param-name>
>      <param-value>debug</param-value>
>    </init-param>
> <init-param>
>   <param-name>dbUrl</param-name>
>      <param-value>jdbc:mysql://localhost:3306</param-value>
>    </init-param>
> <init-param>
>   <param-name>dbName</param-name>
>      <param-value>wwa_m01</param-value>
>    </init-param>
> <init-param>
>   <param-name>dbDriver</param-name>
>      <param-value>org.gjt.mm.mysql.Driver</param-value>
>    </init-param>
> <init-param>
>   <param-name>dbPassword</param-name>
>      <param-value></param-value>
>    </init-param>
> <init-param>
>   <param-name>dbUser</param-name>
>      <param-value>root</param-value>
>    </init-param>
>    <load-on-startup>1</load-on-startup>
>  </servlet>
>
>
>  <!-- Standard Action Servlet Configuration (with debugging) -->
>   <servlet>
>    <servlet-name>action</servlet-name>
>    <servlet-class>PIActionServlet</servlet-class>
>    <init-param>
>      <param-name>application</param-name>
>      <param-value>ApplicationResources</param-value>
>    </init-param>
>    <init-param>
>      <param-name>config</param-name>
>      <param-value>/WEB-INF/struts-config.xml</param-value>
>    </init-param>
>    <init-param>
>      <param-name>debug</param-name>
>      <param-value>2</param-value>
>    </init-param>
>    <init-param>
>      <param-name>detail</param-name>
>      <param-value>1</param-value>
>    </init-param>
>    <init-param>
>      <param-name>validate</param-name>
>      <param-value>true</param-value>
>    </init-param>
>    <load-on-startup>2</load-on-startup>
>  </servlet>
>
>  <!-- Standard Action Servlet Mapping -->
>   <servlet-mapping>
>    <servlet-name>action</servlet-name>
>    <url-pattern>/app/*</url-pattern>
>  </servlet-mapping>
>
>
>  <!-- Struts Tag Library Descriptors -->
>  <taglib>
>    <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
>    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
>  </taglib>
>
>  <taglib>
>    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
>    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
>  </taglib>
>
>  <taglib>
>    <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
>    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
>  </taglib>
>
>  <taglib>
>    <taglib-uri>/WEB-INF/struts-form.tld</taglib-uri>
>    <taglib-location>/WEB-INF/struts-form.tld</taglib-location>
>  </taglib>
>
>   <taglib>
>    <taglib-uri>/WEB-INF/struts.tld</taglib-uri>
>    <taglib-location>/WEB-INF/struts.tld</taglib-location>
>  </taglib>
>
> <taglib>
>    <taglib-uri>/WEB-INF/logon.tld</taglib-uri>
>    <taglib-location>/WEB-INF/logon.tld</taglib-location>
>  </taglib>
> <resource-ref>
> <description>
>    Resource reference to a factory for java.sql.Connection
>    instances that may be used for talking to a particular
>    database that is configured in the server.xml file.
>  </description>
>  <res-ref-name>jdbc/wwa-mDB</res-ref-name>
>  <res-type>javax.sql.DataSource</res-type>
>  <res-auth>Container</res-auth>
></resource-ref>
>
></web-app>


Mime
View raw message