I am trying to learn spring. I did the Step-by-step tutorial twice on two seperate machines. I am able to complete the tutorial up to step 4. When I try to link to the data base, this is the error that is always thrown.
I am probably missing something obvious. Any help would be greatly appreicated.
Here is the springapp-servlet.xmlCode:javax.servlet.ServletException: Servlet.init() for servlet springapp threw exception org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164) org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:732) org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688) java.lang.Thread.run(Thread.java:534) root cause org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springappController' defined in resource [/WEB-INF/springapp-servlet.xml] of ServletContext: Can't resolve reference to bean 'prodMan' while setting property 'productManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'prodMan' defined in resource [/WEB-INF/springapp-servlet.xml] of ServletContext: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'productManagerDao' of bean class [bus.ProductManager]: Property 'productManagerDao' is not writable org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:958) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:889) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:827) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:662) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:270) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136) org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:236) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:284) org.springframework.web.context.support.XmlWebApplicationContext.refresh(XmlWebApplicationContext.java:131) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:282) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:230) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:200) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:102) javax.servlet.GenericServlet.init(GenericServlet.java:256) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164) org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:732) org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688) java.lang.Thread.run(Thread.java:534)
web.xmlCode:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <!-- - Application context definition for "springapp" DispatcherServlet. --> <beans> <!-- Controller for the initial "Hello" page --> <bean id="springappController" class="web.SpringappController"> <property name="productManager"> <ref bean="prodMan"/> </property> </bean> <!-- Validator and Form Controller for the "Price Increase" page --> <bean id="priceIncreaseValidator" class="bus.PriceIncreaseValidator"/> <bean id="priceIncreaseForm" class="web.PriceIncreaseFormController"> <property name="sessionForm"><value>true</value></property> <property name="commandName"><value>priceIncrease</value></property> <property name="commandClass"><value>bus.PriceIncrease</value></property> <property name="validator"><ref bean="priceIncreaseValidator"/></property> <property name="formView"><value>priceincrease</value></property> <property name="successView"><value>hello.htm</value></property> <property name="productManager"> <ref bean="prodMan"/> </property> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property> <property name="url"> <value>jdbc:mysql://localhost:3306/test</value> </property> <property name="username"><value>admin</value></property> <property name="password"><value></value></property> </bean> <bean id="prodManDao" class="db.ProductManagerDaoJdbc"> <property name="dataSource"> <ref bean="dataSource"/> </property> </bean> <bean id="prodMan" class="bus.ProductManager"> <property name="productManagerDao"> <ref bean="prodManDao"/> </property> <!-- <property name="products"> <list> <ref bean="product1"/> <ref bean="product2"/> <ref bean="product3"/> </list> </property> --> </bean> <!-- <bean id="product1" class="bus.Product"> <property name="description"><value>Lamp</value></property> <property name="price"><value>5.75</value></property> </bean> <bean id="product2" class="bus.Product"> <property name="description"><value>Table</value></property> <property name="price"><value>75.25</value></property> </bean> <bean id="product3" class="bus.Product"> <property name="description"><value>Chair</value></property> <property name="price"><value>22.79</value></property> </bean> --> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename"><value>messages</value></property> </bean> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/hello.htm">springappController</prop> <prop key="/priceincrease.htm">priceIncreaseForm</prop> </props> </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> </beans>
[/code]Code:<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <jsp-config> <jsp-property-group> <description> Property group for common configuration for all the JSP's </description> <url-pattern>*.jsp</url-pattern> <el-ignored>true</el-ignored> </jsp-property-group> </jsp-config> <servlet> <servlet-name>springapp</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springapp</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>


Reply With Quote