I'm having trouble properly configuring my app's web interface. Here are my configuration files:
applicationContext.xml
quoteScape-servlet.xml:Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"><value>org.postgresql.Driver</value></property> <property name="url"><value>jdbc:postgresql://localhost:5432/QUOTESCAPE</value></property> <property name="username"><value>postgres</value></property> <property name="password"><value>postgres</value></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"><ref local="dataSource"/></property> <property name="configLocation"> <value>classpath:/hibernate.cfg.xml</value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">net.sf.hibernate.dialect.PostgreSQLDialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> <bean id="quoteScapeBusinessTarget" class="com.quotescape.domain.logic.QuoteScapeImpl"> <property name="categoryDao"><ref bean="categoryDao"/></property> <property name="quoteDao"><ref bean="quoteDao"/></property> <property name="imageDao"><ref bean="imageDao"/></property> </bean> <!-- QuoteScape primary business object. --> <bean id="quoteScapeBusiness" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref local="transactionManager"/></property> <property name="target"><ref local="quoteScapeBusinessTarget"/></property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="categoryDao" class="com.quotescape.dao.hibernate.HibernateCategoryDao"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> <bean id="quoteDao" class="com.quotescape.dao.hibernate.HibernateQuoteDao"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> <bean id="imageDao" class="com.quotescape.dao.hibernate.HibernateImageDao"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> </beans>
web.xml:Code:<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <!-- - DispatcherServlet application context for QuoteScape. --> <beans> <!-- Configurer that sets up a VelocityEngine for Velocity views --> <bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="resourceLoaderPath"><value>WEB-INF/views/</value></property> </bean> <!-- Simple ViewResolver for Velocity, appending ".vm" to logical view names --> <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> <property name="suffix"><value>.vm</value></property> </bean> <!-- HandlerMapping that dispatches all request to the MultiActionController below --> <bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="defaultHandler"><ref local="quoteScapeController"/></property> </bean> <!-- MultiActionController that defines user interface actions as separate methods --> <bean id="quoteScapeController" class="com.quotescape.web.QuoteScapeController"> <property name="methodNameResolver"><ref local="quoteScapeControllerResolver"/></property> <property name="quoteScape"><ref bean="quoteScapeBusiness"/></property> </bean> <!-- Method resolution strategy for the MultiActionController above --> <bean id="quoteScapeControllerResolver" class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver"> <property name="mappings"> <props> <prop key="/categoryList">showCategoryList</prop> </props> </property> </bean> </beans>
I drop the war file into my Tomcat 5.0.28 webapps folder and see in the console that the web app was configured successfully. I can bring up the index.html page in the browser, but when I try to bring up quotescape/categoryList, I get an error message:Code:<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>QuoteScape Enterprise Manager</display-name> <description>Interface for managing the QuoteScape enterprise.</description> <!-- - Location of the XML file that defines the root application context. - Applied by ContextLoaderServlet. --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <!-- - Loads the root application context of this web app at startup, - by default from "/WEB-INF/applicationContext.xml". - Note that it is preferable to use ContextLoaderListener in a servlet container - that follows the Servlet 2.4 initialization order (most Servlet 2.3 containers do). - - Use WebApplicationContextUtils.getWebApplicationContext(servletContext) - to access it anywhere in the web application, outside of the framework. - - The root context is the parent of all servlet-specific contexts. - This means that its beans are automatically available in these child contexts, - both for getBean(name) calls and (external) bean references. --> <servlet> <servlet-name>context</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- - Spring web MVC servlet that dispatches request to registered handlers. - Has its own application context, by default defined in "{servlet-name}-servlet.xml", - i.e. "quoteScape-servlet.xml" in this case. - - A web app can contain any number of such servlets. - Note that this web app has a shared root application context, serving as parent - of all DispatcherServlet contexts. --> <servlet> <servlet-name>quoteScape</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <!-- - Dispatcher servlet mapping for the web user interface, - refering to the "quotescape" servlet above. --> <servlet-mapping> <servlet-name>quoteScape</servlet-name> <url-pattern>/quotescape/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
The requested resource (/quotescape/categoryList) is not available.
Also, it may help if I include my controller class:
What am I doing wrong?Code:/* * Created on Nov 7, 2004 */ package com.quotescape.web; import com.quotescape.domain.logic.QuoteScapeFacade; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ApplicationContextException; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.multiaction.MultiActionController; /** * Primary controller for QuoteScape's web interface. * @author Mike Lenyon */ public class QuoteScapeController extends MultiActionController implements InitializingBean { /** Holds value of property quoteScape. */ private QuoteScapeFacade quoteScape; /** Setter for property quoteScape. * @param quoteScape New value of property quoteScape. */ public void setQuoteScape(QuoteScapeFacade quoteScape) { this.quoteScape = quoteScape; } public void afterPropertiesSet() throws Exception { if (quoteScape == null) throw new ApplicationContextException("Must set quoteScape bean property on " + getClass()); } public ModelAndView showCategoryList() { return new ModelAndView("categoryList", "categories", this.quoteScape.getAllCategories()); } }
TIA,
TTT


Reply With Quote
