Boa noite,
Estou iniciando o estudo no spring framework e estou acompanhando uma configuração básica através do artigo no link http://www.edsongoncalves.com.br/2010/02/27/spring-mvc-3-0-na-pratica-parte-1/.
Baixei o spring framework do site http://www.springsource.org/download versão spring-framework-3.0.2.RELEASE
Crieu no eclipse um novo projeto do tipo Dynamic Web Project e segui o artigo.
Adicionei ao projetos os jars listados abaixo, criei um novo diretório dentro do projeto, o renomeando para lib e copiei e colei os jars dentro desse diretório, arrastando posteriormente para a pasta lib do WEB-INF.
[quote]
org.springframework.asm-sources-3.0.2.RELEASE.jar
org.springframework.asm-3.0.2.RELEASE.jar
org.springframework.beans-3.0.2.RELEASE.jar
org.springframework.context-3.0.2.RELEASE.jar
org.springframework.context.support-3.0.2.RELEASE.jar
org.springframework.core-3.0.2.RELEASE.jar
org.springframework.expression-3.0.2.RELEASE.jar
org.springframework.web-3.0.2.RELEASE.jar
org.springframework.web.servlet-3.0.2.RELEASE.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
com.springsource.org.apache.commons.logging-sources-1.1.1.jar[/quote]
Posteriormente, configurei o arquivo web.xml da seguinte forma:
[code]<?xml version="1.0" encoding="UTF-8"?>
ProjetoSpring
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
[/code]
Criei o arquivo springmvc-servlet.xml da seguinte forma:
[code]<?xml version="1.0" encoding="UTF-8"?>
<context:component-scan base-package="br.com.integrator.web"/>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
[/code]
Depois de configurado os arquivos xml, criei a classe que serve como controller da seguinte forma:
[code]package br.projetospring.olamundo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class OlaMeuController {
@RequestMapping("/ola")
public ModelAndView ola() {
String menssagem = "Conhecendo o Spring Framework";
ModelAndView modelandview = new ModelAndView("ola");
modelandview.addObject("menssagem", menssagem);
return modelandview;
}
}[/code]
Startei o servidor tomcat 6 e tentei acessar a pagina através do browser por meio da url http://localhost:8080/ProjetoSpring/ola, que retorna a seguinte saída no browser:
[quote]HTTP Status 404 -
type Status report
message
description The requested resource () is not available.
Apache Tomcat/6.0.26[/quote]
O console do eclipse exibe as seguintes mensagens:
[quote]06/04/2010 20:15:46 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\MySQL\MySQL Server 5.1\bin
06/04/2010 20:15:46 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:ProjetoSpring’ did not find a matching property.
06/04/2010 20:15:46 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
06/04/2010 20:15:46 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 572 ms
06/04/2010 20:15:46 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
06/04/2010 20:15:46 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
06/04/2010 20:15:47 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet ‘springmvc’
06/04/2010 20:15:47 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet ‘springmvc’: initialization started
06/04/2010 20:15:47 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace ‘springmvc-servlet’: startup date [Tue Apr 06 20:15:47 BRT 2010]; root of context hierarchy
06/04/2010 20:15:47 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/springmvc-servlet.xml]
06/04/2010 20:15:47 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@193f6e2: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0]; root of factory hierarchy
06/04/2010 20:15:48 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet ‘springmvc’: initialization completed in 827 ms
06/04/2010 20:15:48 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
06/04/2010 20:15:48 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
06/04/2010 20:15:48 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/32 config=null
06/04/2010 20:15:48 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1423 ms
06/04/2010 20:16:00 org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ProjetoSpring/ola] in DispatcherServlet with name ‘springmvc’
06/04/2010 20:16:04 org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ProjetoSpring/ola] in DispatcherServlet with name ‘springmvc’[/quote]
Ao que entendi, ele encontra problemas no mapeamento da classe DispatcherServlet, que parece ser acusado no console ao ser carregado o servidor:
E não encontra a pagina :
Estou certo?
Alguém saberia me orientar algum caminho para seguir e encontrar o problema, já que aparentemente segui o artigo apenas tomando alguns outros caminho, mas que acredito não causarem problemas?
Agradeço