tags:

views:

39

answers:

2

In the web.xml of my web app I have configured the server as following:

 <servlet>
  <servlet-name>SOS</servlet-name>
  <servlet-class>cn.SOS</servlet-class>
  <init-param>
   <param-name>configFile</param-name>
   <param-value>/WEB-INF/conf/sos.config</param-value>
  </init-param>
  <init-param>
   <param-name>dbConfigFile</param-name>
   <param-value>/WEB-INF/conf/dssos.config</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>SOS</servlet-name>
  <url-pattern>/sos</url-pattern>
 </servlet-mapping>

However when I request this servlet ,I got a error which tells me "Servlet SOS is not available", but I am sure this servlet do exist in the WEB-INFO/lib/sos.jar. And I have seen the initialization work under the servlet from the logs. I wonder why can not tomcat find the servlet?

A: 

It is not just about entry in web.xml. Servlet instance should be available when request is served. Mostly your servlet instance may not available due to some exception. Check you log file to find more clue.

Also review servlet's init method code. Mostly some operation might have failed.

I found no exceptions in the log.
hguser
+1  A: 

In short: either of

HttpServlet SOS = new cn.SOS();
SOS.init(servletConfig);
SOS.init();

has failed.

Read the appserver logs for the cause and fix the problem accordingly based on the exception and the stacktrace. If you can't find anything in the logs, then most likely something failed during logging. Is the logger properly configured?

Another cause can also be that you're looking in the wrong logs. In Tomcat, unrecovered exceptions are usually logged to the stderr and that usually doesn't end up in the same logfile as the stdout. Even more, it is entirely dependent on the logging configuration.

I'd say: run a debugger if you really can't get out yourself with regard to logging.

BalusC