tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Borut Hadžialić <>
Subject Re: Tomcat 5.5.30 and Spring Framework
Date Fri, 11 Mar 2011 15:30:00 GMT
Do not put anything in $TOMCAT_HOME/conf/web.xml - leave that file as
it is when you unpack a fresh Tomcat distribution.

Why the servlet is not being loaded?  - not 100% about this, but I
would first check if it is maybe being lazy loaded/initialized. After
your tomcat starts up, try to browse http://localhost:8080/test.htm -
that http request will be mapped to your spring servlet, and it will
trigger the initialization of your spring servlet (if that was the
problem in the first place, but i think it is).

The exception you were getting meant that your DispatcherServlet
couldn't find and load its configuration file at startup.
A DispatcherServlet's configuration file is by default
/WEB-INF/<servlet-name>-servlet.xml'. <servlet-name> is 'spring' in
your case - that is how you named it inside web.xml:


So your DispatcherServlet instance that you named 'spring' tried to
load the file /WEB-INF/spring-servlet.xml, which wasn't there and you
got the exception: Could not open ServletContext resource

Make sure you have 'spring' DispatcherServlet's configuration in a
file /WEB-INF/spring-servlet.xml, or use some other file with
configuration like this:


On Fri, Mar 11, 2011 at 4:08 PM, Aureliusz R. <> wrote:
> Borut,
> your instructions were spot on. I was able to track down my docBase
> folder (it was specified in $TOMCAT_HOME/conf/servlet.xml <context>,
> and I verified that it's the correct location by adding some context
> parameters to the web.xml in my docBase, and then retrieving them from
> a JSP.
> Now I have another problem though. For some reason, my
> DispatcherSetvlet (for the spring framework) is not being loaded at
> all. I tried placing the piece of XML below in the
> $TOMCAT_HOME/conf/web.xml and my docBase/WEB-INF/web.xml. I also
> specified invalid fully qualified name for my DispatcherServlet to get
> some kind of exception, but I don't get anything. Is there anything
> that would prevent this servlet from being loaded?
>    <servlet-mapping>
>        <servlet-name>spring</servlet-name>
>        <url-pattern>*.htm</url-pattern>
>    </servlet-mapping>
>  It's ridiculous because some time ago when I placed it in
> $TOMCAT_HOME/conf/web.xml I was getting the exception below, and
> that's the reason why I wanted to know where my docBase is in the
> first place. Now that I know where it is, the DispatcherServlet
> doesn't seem to be loaded at all. Is there anything that would prevent
> this servlet from being loaded?
> org.springframework.beans.factory.BeanDefinitionSt oreException:
> IOException parsing XML document from ServletContext resource
> [/WEB-INF/spring-servlet.xml]; nested exception is
> Could not open ServletContext resource
> [/WEB-INF/spring-servlet.xml]
> Thanks,
> Aurir_
> On Tue, Mar 8, 2011 at 2:47 AM, Borut Hadžialić
> <> wrote:
>> The piece of xml you posted looks like something from
>> $TOMCAT_HOME/conf/web.xml file. This file contains some default
>> configuration that is applied to all web applications and you usually
>> don't change it.
>> What you need to find is the /WEB-INF directory of your web
>> application. /WEB-INF directory resides in the root directory of your
>> web application. This directory is also called Context Root / Document
>> Base - its the directory that contains all files of your app. You
>> usually put spring config files in the /WEB-INF directory of your web
>> application.
>> It doesn't matter where individual applications are on the disk (where
>> their Context Root / Document Base directories are). Applications can
>> be in $TOMCAT_HOME/webapps, or in some other directories anywhere on
>> the filesystem.
>> To figure out where your application's Context Root / Document Base is
>> you can do this:
>> 1. use find to search for WEB-INF directories on your filesystem
>> 2. find your Tomcat's instance conf directory ($TOMCAT_HOME/conf) and
>> go trough the config files there: first look at server.xml - look for
>> <Host> elements and see if it has a appBase attribute defined. Then
>> check if the <Host> element has any <Context> child elements. If it
>> does, their docBase attribute points to document base of an
>> application.
>> If you don't find it there, look for subdirectories in conf directory
>> - for example there might be subdirectories Catalina/localhost that
>> contain individual application xml config files. Those files also
>> contain <Context> elements - look for their docBase attribute.
>> On Tue, Mar 8, 2011 at 4:47 AM, Aureliusz R. <> wrote:
>>> I know this is not a typical tomcat question but please bear with me.
>>> All Spring integrations call for placing configuration xmls in
>>> /WEB-INF/ of an application. The tomcat that I'm forced to work with
>>> has a weird configuration where there are no applications under
>>> $TOMCAT_HOME/webapps folder. There is one folder where all of the
>>> servlets go, and the invoker servlet is mapped to it:
>>> <servlet-mapping>
>>>  <servlet-name>invoker</servlet-name>
>>>  <url-pattern>/servlets/*</url-pattern>
>>> </servlet-mapping>
>>> My question is, how do I know where the context (default context?) in
>>> such a situation is, so that I could place my spring configuration
>>> files in there? Is spring usage even possible with such configuration?
>>> Thanks
>>> Aurir_
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:
>>> For additional commands, e-mail:
>> --
>> Why?
>> Because YES!
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Because YES!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message