while trying to develop a simple database-application with spring mvc I get the following error..
the dispatcher-servlet.xml looks like this:Code:java.io.FileNotFoundException: class path resource [WEB-INF/dispatcher-servlet.xml] cannot be opened because it does not exist at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
and it is called form here:Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/util"> <context:component-scan base-package="net.roseindia.controllers"/> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix"> <value>/WEB-INF/views/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> <bean id = "dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost:3306/springdbtest</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>MySQL2012pwd</value> </property> </bean> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource"> <ref bean="dataSource" /> </property> </bean> <bean id="personDAO" class="net.roseindia.controllers.PersonDAOIMpl"> <property name="jdbcTemplate"> <ref bean="jdbcTemplate" /> </property> </bean> </beans>
I don't know, what's wrong with this, because the mapping via viewResolver works...Code:public ModelAndView helloWorld() { String message = "Hello World, Spring 3.0!"; ApplicationContext ac = new ClassPathXmlApplicationContext("WEB-INF/dispatcher-servlet.xml"); PersonDAO personDAO = (PersonDAO) ac.getBean("personDAO"); System.out.println("Verbindung zur Datenbank erfolgreich hergestellt"); return new ModelAndView("helloworld","message",message); }
Does anobody have a solution? I'm new to spring...
perhaps I've forgotten something..


Reply With Quote
