Results 1 to 8 of 8

Thread: NoSuchElementException in DispatcherServlet

  1. #1
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default NoSuchElementException in DispatcherServlet

    I have just tried upgrading to spring 1.1.3 from 1.1

    In 1.1.3 it seems that whenever I try to do an include (whether jsp:include, c:import, requestDespatcher.include()), I get a NoSuchElementException from DispatcherServlet, in the finally block of doService(), shortly after the comment 'Restore the original attribute snapshot, in case of an include.'

    Here's the stack trace:
    Code:
    org.apache.jasper.JasperException
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:97)
    	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:247)
    	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:784)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:621)
    	org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:368)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:319)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    
    root cause
    
    java.util.NoSuchElementException
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:648)
    	org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:368)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:319)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    	org.apache.jsp.WEB_002dINF.jsp.pagedisplay_jsp._jspService(pagedisplay_jsp.java:161)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:97)
    	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:247)
    	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:784)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:621)
    	org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:368)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:319)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    Chris Harris
    Carlisle, UK

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Chris,

    Can you post your web.xml and web application context config files?

    Rob

  3. #3
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    Here's my web.xml and web application context.
    I also use an extended DispatcherServlet class, and while I can't see how that would affect the problem, I'm including that as well just in case . . .

    web.xml
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <!--!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http&#58;//java.sun.com/dtd/web-app_2_3.dtd"-->
    
    <!--web-app-->
    <web-app    xmlns="http&#58;//java.sun.com/xml/ns/j2ee"
                xmlns&#58;xsi="http&#58;//www.w3.org/2001/XMLSchema-instance"
                xsi&#58;schemaLocation="http&#58;//java.sun.com/xml/ns/j2ee
                                    http&#58;//java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
                version="2.4">
    
        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>
                    /WEB-INF/config/wo_web_config.xml
                </param-value>
        </context-param>
    
        <listener>
            <listener-class>org.stl.wo.web.SessionCounterListener</listener-class>
        </listener>
    
        <servlet>
            <servlet-name>woapp</servlet-name>
            <!--servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class-->
            <servlet-class>org.stl.wo.web.CustomContextDispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>woapp</servlet-name>
            <url-pattern>*.htm</url-pattern>
        </servlet-mapping>
    
        <servlet-mapping>
            <servlet-name>woapp</servlet-name>
            <url-pattern>*.page</url-pattern>
        </servlet-mapping>
    
        <session-config>
            <session-timeout>30</session-timeout>
        </session-config>
    
        <welcome-file-list>
            <welcome-file>
                index.jsp
            </welcome-file>
        </welcome-file-list>
    
        <!-- to get JNDI datasource to work in jstl&#58; -->
        <!-- this,together with a wodata resourceref in jboss-web.xml, and the
             contextparam at the top, are needed to make a default datasource available to JSTL SQL tags.-->
        <resource-ref>
            <description>data source</description>
            <res-ref-name>wodata</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
        </resource-ref>
        
        <error-page>
            <error-code>404</error-code>
            <location>/pagenotfound.htm</location>
        </error-page>
    </web-app>
    Web application context:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans
      PUBLIC "-//SPRING//DTD BEAN//EN"
      "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    
        <bean id="woappController" class="org.stl.wo.web.WoappController">
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="pafService"><ref bean="pafrmi"/></property>
        </bean>
    
        <bean id="siteIdResolver" class="org.stl.wo.web.SiteIdResolver">
            <property name="urlMap"><ref bean="urlMap"/></property>
        </bean>
    
        <bean id="pageCtlr" class="org.stl.wo.web.PageController">
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="view"><value>pagedisplay</value></property>
            <property name="pageNotFoundKeyName"><value>nopage</value></property>
        </bean>
    
        <bean id="listCtlr" class="org.stl.wo.web.ListController">
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="view"><value>listdisplay</value></property>
        </bean>
    
        <bean id="eventsCtlr" class="org.stl.wo.web.EventController">
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="view"><value>eventdisplay</value></property>
        </bean>
    
        <bean id="customerCtlr" class="org.stl.wo.web.cust.CustomerDetailsController">
            <property name="commandName"><value>customer</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.cust.Customer</value></property>
            <property name="formView"><value>customer</value></property>
            <property name="successView"><value>customer</value></property>
            <!-- sessionForm is true because the passwordHash must persist in the command object from
                 form request to form submission -->
            <property name="sessionForm"><value>true</value></property>
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="pafService"><ref bean="pafrmi"/></property>
            <property name="validator"><ref bean="customerValidator"/></property>
            <property name="custRefData"><ref bean="custRefData"/></property>
            <property name="newUrl"><value>newcustomer.htm</value></property>
            <property name="updateUrl"><value>updatecustomer.htm</value></property>
            <property name="passwordUrl"><value>customerpassword.htm</value></property>
            <property name="transactionManager"><ref bean="woTransactionManager"/></property>
        </bean>
    
        <bean id="productDisplayForm" class="org.stl.wo.web.prod.ProdDisplayController">
            <!--property name="sessionForm"><value>true</value></property-->
            <property name="commandName"><value>searchCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.prod.SearchCmnd</value></property>
            <property name="validator"><ref bean="searchCmndValidator"/></property>
            <property name="formView"><value>productdisplay</value></property>
            <property name="successView"><value>productdisplay</value></property>
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="imageServer"><value>$&#123;imageServer&#125;</value></property>
            <property name="vat"><ref bean="vat"/></property>
            <property name="offers"><ref bean="offers"/></property>
            <property name="category"><ref bean="category"/></property>
        </bean>
    
        <bean id="browseCat" class="org.stl.wo.web.prod.BrowseCatController">
            <property name="sessionForm"><value>true</value></property>
            <property name="bindOnNewForm"><value>true</value></property>
            <property name="commandName"><value>browseCatCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.prod.BrowseCatCmnd</value></property>
            <property name="formView"><value>browsecat</value></property>
            <property name="successView"><value>browsecat</value></property>
            <property name="category"><ref bean="category"/></property>
        </bean>
    
        <bean id="siteIdCtlr" class="org.stl.wo.web.SiteIdFormController">
            <property name="sessionForm"><value>true</value></property>
            <property name="commandName"><value>siteIdCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.web.SiteIdCmnd</value></property>
            <property name="formView"><value>siteid</value></property>
            <property name="successView"><value>siteid</value></property>
            <property name="siteIdResolver"><ref bean="siteIdResolver"/></property>
            <property name="validator"><ref bean="siteIdValidator"/></property>
        </bean>
    
        <bean id="searchCmndValidator" class="org.stl.wo.bus.prod.SearchCmndValidator">
            <property name="searchMaxDisplayLimit"><value>$&#123;searchMaxDisplayLimit&#125;</value></property>
        </bean>
    
        <bean id="search" class="org.stl.wo.web.prod.SearchController">
            <property name="imageServer"><value>$&#123;imageServer&#125;</value></property>
            <!--property name="sessionForm"><value>true</value></property-->
            <property name="commandName"><value>searchCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.prod.SearchCmnd</value></property>
            <property name="formView"><value>searchresults</value></property>
            <property name="successView"><value>searchresults</value></property>
            <!--property name="searchDisplayAtATime"><value>$&#123;searchDisplayAtATime&#125;</value></property-->
            <!--property name="searchMaxDisplay"><value>$&#123;searchMaxDisplay&#125;</value></property-->
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="siteIdResolver"><ref bean="siteIdResolver"/></property>
            <property name="validator"><ref bean="searchCmndValidator"/></property>
            <property name="series"><ref bean="series"/></property>
            <property name="vat"><ref bean="vat"/></property>
            <property name="orderbyClause"><ref bean="orderbyClause"/></property>
            <property name="offers"><ref bean="offers"/></property>
            <property name="category"><ref bean="category"/></property>
        </bean>
    
        <bean id="signonCtlr" class="org.stl.wo.web.cust.SignonController">
            <property name="commandName"><value>signonCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.cust.SignonCmnd</value></property>
            <property name="formView"><value>signon</value></property>
            <property name="successView"><value>signon</value></property>
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="validator"><ref bean="signonValidator"/></property>
            <property name="mailSender"><value>$&#123;mailSender&#125;</value></property>
            <property name="smtpHost"><value>$&#123;smtpHost&#125;</value></property>
            <property name="siteIdResolver"><ref bean="siteIdResolver"/></property>
        </bean>
    
        <bean id="adminSignonCtlr" class="org.stl.wo.web.admin.AdminSignonController">
            <property name="commandName"><value>signonCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.cust.SignonCmnd</value></property>
            <property name="formView"><value>signon</value></property>
            <property name="successView"><value>signon</value></property>
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="validator"><ref bean="signonValidator"/></property>
        </bean>
    
        <bean id="cartValidator" class="org.stl.wo.bus.order.CartValidator"/>
        <bean id="cartCtlr" class="org.stl.wo.web.order.CartController">
            <property name="offers"><ref bean="offers"/></property>
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="vat"><ref bean="vat"/></property>
            <property name="commandName"><value>cartCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.order.CartCmnd</value></property>
            <property name="formView"><value>cart</value></property>
            <property name="successView"><value>cart</value></property>
            <property name="imageServer"><value>$&#123;imageServer&#125;</value></property>
            <property name="validator"><ref bean="cartValidator"/></property>
            <property name="category"><ref bean="category"/></property>
        </bean>
    
        <bean id="checkoutCtlr" class="org.stl.wo.web.order.CheckoutController">
            <property name="pipeLineFactory">
                <bean class="org.stl.wo.bus.PipeLineFactory" init-method="initialize">
                    <property name="pipeList"><ref bean="pipelinelist"/></property>
                    <property name="finalUrl"><value>confirmorder.htm</value></property>
                </bean>
            </property>
            <property name="carriageRateResolverFactory"><ref bean="carriageRateResolverFactory"/></property>
        </bean>
    
        <bean id="deliveryCtlr" class="org.stl.wo.web.order.DeliveryController">
            <!-- nb addressValidator, not validator, so it isn't invoked automatically -->
            <property name="addressValidator"><ref bean="addressValidator"/></property>
            <property name="commandName"><value>deliveryCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.cust.Address</value></property>
            <property name="formView"><value>delivery</value></property>
            <!--property name="successView"><value>delivery</value></property-->
            <property name="custRefData"><ref bean="custRefData"/></property>
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
        </bean>
    
        <bean id="carriageCtlr" class="org.stl.wo.web.order.CarriageController">
            <property name="commandName"><value>dummyCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.DummyCmnd</value></property>
            <property name="formView"><value>carriage</value></property>
            <property name="successView"><value>carriage</value></property>
        </bean>
    
        <bean id="profileCtlr" class="org.stl.wo.web.cust.CustomerProfileController">
            <property name="commandName"><value>dummyCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.DummyCmnd</value></property>
            <property name="formView"><value>profile</value></property>
            <property name="nextPageView"><value>profile</value></property>
            <property name="finalView"><value>profiledisplay</value></property>
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="transactionManager"><ref bean="woTransactionManager"/></property>
        </bean>
    
        <bean id="appcontrolCtlr" class="org.stl.wo.web.admin.AppControlController">
            <property name="jobName"><value>AppControlPage</value></property>
            <property name="commandName"><value>dummyCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.DummyCmnd</value></property>
            <property name="formView"><value>appcontrol</value></property>
            <property name="successView"><value>appcontrol</value></property>
            <property name="carriageRateResolverFactory"><ref bean="carriageRateResolverFactory"/></property>
            <property name="offers"><ref bean="offers"/></property>
            <property name="unloader"><ref bean="orderUnloader"/></property>
        </bean>
    
        <bean id="updateorderCtlr" class="org.stl.wo.web.order.UpdateOrderController">
            <property name="commandName"><value>cartCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.order.CartCmnd</value></property>
            <property name="imageServer"><value>$&#123;imageServer&#125;</value></property>
            <property name="formView"><value>updateorder</value></property>
            <property name="successView"><value>updateorder</value></property>
        </bean>
    
        <bean id="confirmorderCtlr" class="org.stl.wo.web.order.ConfirmOrderController">
            <property name="commandName"><value>cartCmnd</value></property>
            <property name="commandClass"><value>org.stl.wo.bus.order.CartCmnd</value></property>
            <property name="dataAccessor"><ref bean="dataAccessor"/></property>
            <property name="transactionManager"><ref bean="woTransactionManager"/></property>
            <property name="imageServer"><value>$&#123;imageServer&#125;</value></property>
            <property name="formView"><value>confirmorder</value></property>
            <property name="successView"><value>payment</value></property>
        </bean>
    
        <bean id="signOffCtlr" class="org.stl.wo.web.cust.SignOffController"/>
    
        <bean id="uploadCtlr" class="org.stl.wo.web.admin.FileUploadController">
            <property name="commandClass"><value>org.stl.wo.admin.FileUploadBean</value></property>
            <property name="formView"><value>fileupload</value></property>
            <property name="successView"><value>fileupload</value></property>
            <property name="jobName"><value>fileUpload</value></property>
            <property name="validator"><ref bean="uploadCtlr"/></property>
            <property name="uploadTypes">
                <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
                    <property name="location"><value>WEB-INF/config/fileupload.properties</value></property>
                </bean>
            </property>
            <property name="uploadSizes">
                <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
                    <property name="location"><value>WEB-INF/config/fileuploadsize.properties</value></property>
                </bean>
            </property>
        </bean>
    
        <bean id="cacheCtlr" class="org.stl.wo.web.admin.CacheController">
            <property name="commandClass"><value>org.stl.wo.admin.CacheBean</value></property>
            <property name="formView"><value>cacheadmin</value></property>
            <property name="successView"><value>cacheadmin</value></property>
            <property name="jobName"><value>cacheadmin</value></property>
            <property name="cacheManager"><ref bean="cacheManager"/></property>
        </bean>
    
        <bean id="siteIdInterceptor" class="org.stl.wo.web.SiteIdHandlerInterceptor">
            <property name="siteIdResolver"><ref bean="siteIdResolver"/></property>
            <property name="siteIdServletPath"><value>/siteid.htm</value></property>
            <property name="category"><ref bean="category"/></property>
            <property name="series"><ref bean="series"/></property>
            <property name="orderbyOptions"><ref bean="orderbyOptions"/></property>
            <property name="offers"><ref bean="offers"/></property>
            <property name="searchDisplayAtATime"><value>$&#123;searchDisplayAtATime&#125;</value></property>
            <property name="searchMaxDisplay"><value>$&#123;searchMaxDisplay&#125;</value></property>
            <property name="showDelOps"><value>$&#123;showDelOps&#125;</value></property>
        </bean>
    
        <bean id="registrationInterceptor" class="org.stl.wo.web.RegistrationInterceptor">
            <property name="signonServletPath"><value>signon.htm</value></property>
        </bean>
    
        <bean id="adminJobInterceptor" class="org.stl.wo.web.admin.AdminJobInterceptor">
            <property name="adminSignonServletPath"><value>adminsignon.htm</value></property>
        </bean>
    
        <!-- any url that ends in keyword.anyExtension, where the keyword is in the list below,
             will be forced to use https; and vice-versa. -->
        <bean id="secureInterceptor" class="org.stl.wo.web.SecureInterceptor">
            <property name="secureList">
                <list>
                    <value>signon</value>
                    <value>adminsignon</value>
                    <value>newcustomer</value>
                    <value>customerpassword</value>
                </list>
            </property>
        </bean>
    
        <!-- Interceptors&#58;
             siteIdInterceptor&#58; ensures that we know what site we want&#58; either through the url, or by
                                asking the user. Also makes sure certain commonly needet items are in
                                the model.
                                For all urls.
             registrationInterceptor&#58; Makes sure the user has logged on and is a recognised user.
                                For urls that need to know the user, e.g.  placing an order.
             adminJobInterceptor&#58; Makes sure the user has logged on, and that he is authorised to use this
                                page.
                                For urls that aren't available to everyone, e.g. site admin.
             secureInterceptor  Makes sure that urls in the secureList use https, and others use http
        -->
    
        <!-- These are pages that don't need a valid signon to access&#58; -->
        <bean id="urlMapping1" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="order"><value>1</value></property>
            <property name="mappings">
                <props>
                    <prop key="/*.page">pageCtlr</prop>
                    <prop key="/list.htm">listCtlr</prop>
                    <prop key="/events.htm">eventsCtlr</prop>
                    <prop key="/hello.htm">woappController</prop>
                    <prop key="/siteid.htm">siteIdCtlr</prop>
                    <prop key="/browsecat.htm">browseCat</prop>
                    <prop key="/search.htm">search</prop>
                    <prop key="/productdisplay.htm">productDisplayForm</prop>
                    <prop key="/cart.htm">cartCtlr</prop>
                    <prop key="/signoff.htm">signOffCtlr</prop> 
                    <prop key="/newcustomer.htm">customerCtlr</prop>
                    <prop key="/signon.htm">signonCtlr</prop>
                    <prop key="/adminsignon.htm">adminSignonCtlr</prop>
                    <!--prop key="/test.htm">testCtlr</prop-->
                </props>
            </property>
            <property name="interceptors">
                <list>
                    <ref bean="siteIdInterceptor"/>
                    <ref bean="secureInterceptor"/>
                </list>
            </property>
        </bean>
    
        <!-- These are pages that need a valid signon to access&#58; -->
        <bean id="urlMapping2" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="order"><value>2</value></property>
            <property name="mappings">
                <props>
                    <prop key="/profile.htm">profileCtlr</prop>
                    <prop key="/checkout.htm">checkoutCtlr</prop>
                    <prop key="/delivery.htm">deliveryCtlr</prop>
                    <prop key="/carriage.htm">carriageCtlr</prop>
                    <prop key="/updateorder.htm">updateorderCtlr</prop>
                    <prop key="/confirmorder.htm">confirmorderCtlr</prop>
                    <prop key="/updatecustomer.htm">customerCtlr</prop>
                    <prop key="/customerpassword.htm">customerCtlr</prop>
                </props>
            </property>
            <property name="interceptors">
                <list>
                    <ref bean="siteIdInterceptor"/> 
                    <ref bean="secureInterceptor"/>
                    <ref bean="registrationInterceptor"/>
                </list>
            </property>
        </bean>
    
        <!-- These are pages that need admin role to access&#58; -->
        <bean id="urlMapping3" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="order"><value>3</value></property>
            <property name="mappings">
                <props>
                    <prop key="/appcontrol.htm">appcontrolCtlr</prop>
                    <prop key="/upload.htm">uploadCtlr</prop>
                    <prop key="/cacheadmin.htm">cacheCtlr</prop>
                </props>
            </property>
            <property name="interceptors">
                <list>
                    <ref bean="siteIdInterceptor"/>
                    <ref bean="secureInterceptor"/>
                    <ref bean="adminJobInterceptor"/>
                </list>
            </property>
        </bean>
    
        <!-- Catchall for 'invalid' htm's&#58; -->
        <!-- 404 'page not found' are mapped in web.xml to pagenotfound.htm, so will be cought here -->
        <bean id="urlMapping10" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="order"><value>10</value></property>
            <property name="mappings">
                <props>
                    <prop key="/*.htm">pageCtlr</prop>
                </props>
            </property>
            <property name="interceptors">
                <list>
                    <ref bean="siteIdInterceptor"/>
                    <ref bean="secureInterceptor"/>
                </list>
            </property>
        </bean>
    
        <bean id="resourceBundleViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
            <property name="order"><value>0</value></property>
        </bean>
    
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
            <property name="prefix"><value>/WEB-INF/jsp/</value></property>
            <property name="suffix"><value>.jsp</value></property>
        </bean>
    
        <bean id="exceptionResolver1" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
            <property name="order"><value>1</value></property>
    		<property name="exceptionMappings">
    			<props>
    				<prop key="org.stl.wo.web.Exception.SessionException">sessionfailure</prop>
    				<prop key="org.stl.wo.bus.PipeLineException">pipelinefailure</prop>
                    <prop key="org.stl.wo.bus.UserNotInRoleException">authorisationfailure</prop>
                    <prop key="org.stl.wo.bus.SimpleMessageException">defaultfailure</prop>
    			</props>
    		</property>
    	</bean>
    
        <bean id="exceptionResolver2" class="org.stl.wo.web.StacktraceLoggingExceptionResolver">
            <property name="order"><value>2</value></property>
    		<property name="exceptionMappings">
    			<props>
    				<prop key="java.lang.Exception">defaultfailure</prop>
    			</props>
    		</property>
    	</bean>
    
        <bean id="siteIdValidator" class="org.stl.wo.web.SiteIdValidator">
            <property name="siteIdResolver"><ref bean="siteIdResolver"/></property>
        </bean>
    
        <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
            <property name="basename"><value>messages</value></property>
        </bean>
    
        <bean id="configsetter" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="location"><value>WEB-INF/config/webconfig.properties</value></property>
        </bean>
    
        <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
            <property name="maxUploadSize"><value>1000000</value></property>
        </bean>
    
    </beans>
    CustomContextDispatcherServlet.java:
    Code:
    public class  CustomContextDispatcherServlet extends DispatcherServlet &#123;
        BeanFactoryReference bfr = null;
    
        protected WebApplicationContext initWebApplicationContext&#40;&#41; &#123;
            ContextLoader cl = new MyContextLoader&#40;&#41;;
            WebApplicationContext wac = cl.initWebApplicationContext&#40;this.getServletContext&#40;&#41;&#41;;
            getServletContext&#40;&#41;.setAttribute&#40;"org.springframework.web.servlet.FrameworkServlet.CONTEXT.woapp", wac&#41;;
            return wac;
        &#125;
    
        public void destroy&#40;&#41; &#123;
            // to prevent classloader problems on hot redeploy&#58;
            if &#40;bfr != null&#41; &#123;
                bfr.release&#40;&#41;;
            &#125;
        &#125;
    
        class MyContextLoader extends ContextLoader &#123;
            protected ApplicationContext loadParentContext&#40;ServletContext servletContext&#41; &#123;
                //System.out.println&#40;"overriding loadParentContext"&#41;;
                BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance&#40;&#41;;
                bfr = bfl.useBeanFactory&#40;"org.stl.wo.appcontext"&#41;;
                return &#40;ApplicationContext&#41;bfr.getFactory&#40;&#41;;
            &#125;
        &#125;
    &#125;
    Chris Harris
    Carlisle, UK

  4. #4
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Try adding the following definition to your servlet declaration.

    Code:
    		<init-param>
    			<param-name>cleanupAfterInclude</param-name>
    			<param-value>false</param-value>
    		</init-param>
    Rob[/code]

  5. #5
    Join Date
    Aug 2004
    Location
    Hawaii, US
    Posts
    225

    Default

    Just a note, but we use 1.1.3 and c:import statements, and all appears fine.

  6. #6
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    Rob,

    Thanks for the suggestion. If I set cleanupAfterInclude to false, as you suggest, I don't get the error. But I also don't get the cleanup functionality (which I hadn't realised I needed, but in fact I do).

    To investigate further, I overrode doService() in my own CustomContextDespatcherServlet to do some debugging. Below I've posted the doService() code, and its output.
    I really don't understand what's going on here; the only explanation I can come up with is that resetting some of the request attributes messes up the getAttributeNames Enumeration. The Enumeration javadoc doesn't comment on whether this is safe or not.

    I created a working version by copying the results of the Enumeration to an ArrayList, and then iterating over that. That worked exactly as expected, reinforcing my tentative explanation above. I include that code at the bottom of the post.

    doService() like the one in DespatcherServlet, fails:
    line 91, where the exception occurs, is String attrName = (String) attrNames.nextElement();
    Code:
        protected void doService&#40;HttpServletRequest request, HttpServletResponse response&#41; throws Exception &#123;
            Enumeration attrNames = request.getAttributeNames&#40;&#41;;
    
    		Map attributesSnapshot = null;
    		if &#40;request.getAttribute&#40;UrlPathHelper.INCLUDE_URI_REQUEST_ATTRIBUTE&#41; != null&#41; &#123;
    			logger.info&#40;"Taking snapshot of request attributes before include"&#41;;
    			attributesSnapshot = new HashMap&#40;&#41;;
    			attrNames = request.getAttributeNames&#40;&#41;;
    			while &#40;attrNames.hasMoreElements&#40;&#41;&#41; &#123;
    				String attrName = &#40;String&#41; attrNames.nextElement&#40;&#41;;
                    logger.info&#40;"Name&#58; " + attrName&#41;;
    				attributesSnapshot.put&#40;attrName, request.getAttribute&#40;attrName&#41;&#41;;
    			&#125;
    		&#125;
    
            super.doService &#40;request, response&#41;;
    
    
            logger.info&#40;"Current Request Attributes before cleanup&#58;"&#41;;
            attrNames = request.getAttributeNames&#40;&#41;;
            while &#40;attrNames.hasMoreElements&#40;&#41;&#41; &#123;
                String attrName = &#40;String&#41; attrNames.nextElement&#40;&#41;;
                logger.info&#40;"Name&#58; " + attrName&#41;;
            &#125;
    
            if &#40;attributesSnapshot != null&#41; &#123;
                logger.info&#40;"Restoring snapshot of request attributes after include"&#41;;
                attrNames = request.getAttributeNames&#40;&#41;;
                while &#40;attrNames.hasMoreElements&#40;&#41;&#41; &#123;
                    String attrName = &#40;String&#41; attrNames.nextElement&#40;&#41;;
                    if &#40;true || attrName.startsWith&#40;DispatcherServlet.class.getName&#40;&#41;&#41;&#41; &#123;
                        Object attrValue = attributesSnapshot.get&#40;attrName&#41;;
                        if &#40;attrValue != null&#41; &#123;
                            logger.info&#40;"Setting attribute " + attrName&#41;;
                            request.setAttribute&#40;attrName, attrValue&#41;;
                        &#125;
                        else &#123;
                            logger.info&#40;"*******Removing attribute " + attrName&#41;;
                            request.removeAttribute&#40;attrName&#41;;
                        &#125;
                    &#125;
                &#125;
            &#125;
        &#125;
    server log from running the above:
    Code:
    2004-12-20 12&#58;51&#58;19,141 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Taking snapshot of request attributes before include
    2004-12-20 12&#58;51&#58;19,142 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.include.request_uri
    2004-12-20 12&#58;51&#58;19,143 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.include.context_path
    2004-12-20 12&#58;51&#58;19,143 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.include.servlet_path
    2004-12-20 12&#58;51&#58;19,143 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.include.query_string
    2004-12-20 12&#58;51&#58;19,144 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.forward.request_uri
    2004-12-20 12&#58;51&#58;19,144 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.forward.context_path
    2004-12-20 12&#58;51&#58;19,144 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.forward.servlet_path
    2004-12-20 12&#58;51&#58;19,144 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; org.springframework.web.servlet.DispatcherServlet.THEME
    2004-12-20 12&#58;51&#58;19,145 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; org.springframework.web.servlet.DispatcherServlet.CONTEXT
    2004-12-20 12&#58;51&#58;19,145 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; siteId
    2004-12-20 12&#58;51&#58;19,145 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; seriesoptions
    2004-12-20 12&#58;51&#58;19,145 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.jsp.jstl.fmt.localizationContext
    2004-12-20 12&#58;51&#58;19,145 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; searchMaxDisplay
    2004-12-20 12&#58;51&#58;19,146 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; showDelOps
    2004-12-20 12&#58;51&#58;19,146 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.jsp.jstl.fmt.localizationContext.request
    2004-12-20 12&#58;51&#58;19,146 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; now
    2004-12-20 12&#58;51&#58;19,146 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.jsp.jstl.fmt.locale.request
    2004-12-20 12&#58;51&#58;19,147 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.jsp.jstl.fmt.locale
    2004-12-20 12&#58;51&#58;19,147 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; orderbyoptions
    2004-12-20 12&#58;51&#58;19,147 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; catoptions
    2004-12-20 12&#58;51&#58;19,147 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; page
    2004-12-20 12&#58;51&#58;19,148 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; orderofferdescs
    2004-12-20 12&#58;51&#58;19,148 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; searchDisplayAtATime
    2004-12-20 12&#58;51&#58;19,148 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; org.springframework.web.servlet.DispatcherServlet.HANDLER
    2004-12-20 12&#58;51&#58;19,148 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; org.springframework.web.servlet.DispatcherServlet.LOCALE
    2004-12-20 12&#58;51&#58;29,577 INFO  &#91;org.springframework.ui.context.support.ResourceBundleThemeSource&#93; Theme created&#58; name 'theme', basename &#91;theme&#93;
    2004-12-20 12&#58;51&#58;34,168 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Current Request Attributes before cleanup&#58;
    2004-12-20 12&#58;51&#58;34,169 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.include.request_uri
    2004-12-20 12&#58;51&#58;34,169 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.include.context_path
    2004-12-20 12&#58;51&#58;34,169 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.include.servlet_path
    2004-12-20 12&#58;51&#58;34,169 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.include.query_string
    2004-12-20 12&#58;51&#58;34,169 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.forward.request_uri
    2004-12-20 12&#58;51&#58;34,170 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.forward.context_path
    2004-12-20 12&#58;51&#58;34,170 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.forward.servlet_path
    2004-12-20 12&#58;51&#58;34,171 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; product
    2004-12-20 12&#58;51&#58;34,171 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; org.springframework.web.servlet.DispatcherServlet.THEME
    2004-12-20 12&#58;51&#58;34,171 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; org.springframework.web.servlet.DispatcherServlet.CONTEXT
    2004-12-20 12&#58;51&#58;34,171 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; siteId
    2004-12-20 12&#58;51&#58;34,171 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; seriesoptions
    2004-12-20 12&#58;51&#58;34,172 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.jsp.jstl.fmt.localizationContext
    2004-12-20 12&#58;51&#58;34,172 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; searchMaxDisplay
    2004-12-20 12&#58;51&#58;34,172 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; showDelOps
    2004-12-20 12&#58;51&#58;34,172 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.jsp.jstl.fmt.localizationContext.request
    2004-12-20 12&#58;51&#58;34,173 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; now
    2004-12-20 12&#58;51&#58;34,173 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; searchCmnd
    2004-12-20 12&#58;51&#58;34,173 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.jsp.jstl.fmt.locale.request
    2004-12-20 12&#58;51&#58;34,191 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; javax.servlet.jsp.jstl.fmt.locale
    2004-12-20 12&#58;51&#58;34,191 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; org.springframework.validation.BindException.searchCmnd
    2004-12-20 12&#58;51&#58;34,192 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; orderbyoptions
    2004-12-20 12&#58;51&#58;34,192 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; catoptions
    2004-12-20 12&#58;51&#58;34,192 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; page
    2004-12-20 12&#58;51&#58;34,192 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; paramNames
    2004-12-20 12&#58;51&#58;34,193 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; imageServer
    2004-12-20 12&#58;51&#58;34,193 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; orderofferdescs
    2004-12-20 12&#58;51&#58;34,193 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; name
    2004-12-20 12&#58;51&#58;34,193 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; searchDisplayAtATime
    2004-12-20 12&#58;51&#58;34,193 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Name&#58; org.springframework.web.servlet.DispatcherServlet.LOCALE
    2004-12-20 12&#58;51&#58;34,194 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Restoring snapshot of request attributes after include
    2004-12-20 12&#58;51&#58;34,194 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Setting attribute javax.servlet.include.request_uri
    2004-12-20 12&#58;51&#58;34,194 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Setting attribute javax.servlet.include.context_path
    2004-12-20 12&#58;51&#58;34,195 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Setting attribute javax.servlet.include.servlet_path
    2004-12-20 12&#58;51&#58;34,195 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Setting attribute javax.servlet.include.query_string
    2004-12-20 12&#58;51&#58;34,195 INFO  &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Setting attribute javax.servlet.forward.request_uri
    2004-12-20 12&#58;51&#58;34,196 ERROR &#91;org.stl.wo.web.CustomContextDispatcherServlet&#93; Could not complete request
    java.util.NoSuchElementException
    	at org.apache.catalina.core.ApplicationHttpRequest.nextElement&#40;ApplicationHttpRequest.java&#58;868&#41;
    	at org.stl.wo.web.CustomContextDispatcherServlet.doService&#40;CustomContextDispatcherServlet.java&#58;91&#41;

    Version which does work:
    Code:
        protected void doService&#40;HttpServletRequest request, HttpServletResponse response&#41; throws Exception &#123;
            Enumeration attrNames = request.getAttributeNames&#40;&#41;;
    
    		Map attributesSnapshot = null;
    		if &#40;request.getAttribute&#40;UrlPathHelper.INCLUDE_URI_REQUEST_ATTRIBUTE&#41; != null&#41; &#123;
    			logger.info&#40;"Taking snapshot of request attributes before include"&#41;;
    			attributesSnapshot = new HashMap&#40;&#41;;
    			attrNames = request.getAttributeNames&#40;&#41;;
    			while &#40;attrNames.hasMoreElements&#40;&#41;&#41; &#123;
    				String attrName = &#40;String&#41; attrNames.nextElement&#40;&#41;;
                    logger.info&#40;"Name&#58; " + attrName&#41;;
    				attributesSnapshot.put&#40;attrName, request.getAttribute&#40;attrName&#41;&#41;;
    			&#125;
    		&#125;
    
            super.doService &#40;request, response&#41;;
    
    
            logger.info&#40;"Current Request Attributes before cleanup&#58;"&#41;;
            attrNames = request.getAttributeNames&#40;&#41;;
            while &#40;attrNames.hasMoreElements&#40;&#41;&#41; &#123;
                String attrName = &#40;String&#41; attrNames.nextElement&#40;&#41;;
                logger.info&#40;"Name&#58; " + attrName&#41;;
            &#125;
    
            if &#40;attributesSnapshot != null&#41; &#123;
                logger.info&#40;"Restoring snapshot of request attributes after include"&#41;;
                attrNames = request.getAttributeNames&#40;&#41;;
                List names = new ArrayList&#40;&#41;;
                while &#40;attrNames.hasMoreElements&#40;&#41;&#41; &#123;
                    names.add&#40;attrNames.nextElement&#40;&#41;&#41;;
                &#125;
                for &#40;Iterator it = names.iterator&#40;&#41;; it.hasNext&#40;&#41;; &#41; &#123;
                    String attrName = &#40;String&#41;it.next&#40;&#41;;
                    if &#40;true || attrName.startsWith&#40;DispatcherServlet.class.getName&#40;&#41;&#41;&#41; &#123;
                        Object attrValue = attributesSnapshot.get&#40;attrName&#41;;
                        if &#40;attrValue != null&#41; &#123;
                            logger.info&#40;"Setting attribute " + attrName&#41;;
                            request.setAttribute&#40;attrName, attrValue&#41;;
                        &#125;
                        else &#123;
                            logger.info&#40;"*******Removing attribute " + attrName&#41;;
                            request.removeAttribute&#40;attrName&#41;;
                        &#125;
                    &#125;
                &#125;
            &#125;
        &#125;
    Chris Harris
    Carlisle, UK

  7. #7
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    Indeed, that's a bug in the cleanup-on-include functionality of 1.1.3's version of DispatcherServlet. While it works on Resin, for example, it unfortunately may break with such an exception on Tomcat.

    I've already fixed this shortly after the 1.1.3 release. Give a recent nightly 1.1.4-dev snapshot a try, which includes the fix. The current codebase has already been tested by another user that had the same problem - it's reported to work now.

    Let me know whether a 1.1.4-dev snapshot works for you too!

    Juergen

  8. #8
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    Just tried the latest 1.1.4-dev snapshot - works fine!

    Thanks
    Chris Harris
    Carlisle, UK

Similar Threads

  1. Replies: 2
    Last Post: May 19th, 2008, 01:38 PM
  2. DispatcherServlet: No adapter for handler
    By mwormgoor in forum Web Flow
    Replies: 2
    Last Post: Aug 4th, 2005, 04:53 PM
  3. PageNotFound in DispatcherServlet
    By cnelson in forum Web
    Replies: 4
    Last Post: May 4th, 2005, 05:25 AM
  4. Replies: 3
    Last Post: Dec 22nd, 2004, 07:31 AM
  5. Replies: 1
    Last Post: Sep 13th, 2004, 09:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •