Erro misterioso no SpringMVC

2 respostas
M

Prezados Senhores,
Partindo do pressuposto que eu tenho este código em ListStudentControllerImpl

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.edu.casf.jcasf.controller.student.impl;

import br.edu.casf.jcasf.service.student.StudentService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

/**
 *
 * @author Ferrugem
 */
public class ListStudentControllerImpl implements Controller {
    private StudentService studentService;

    /**
     * @return the studentService
     */
    public StudentService getStudentService() {
        return studentService;
    }

    /**
     * @param studentService the studentService to set
     */
    public void setStudentService(StudentService studentService) {
        this.studentService = studentService;
    }

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        return new ModelAndView("list_student.jsp").addObject("students", this.getStudentService().listAllStudents());
    }


}

e este mapeamento:

<bean name="/list_student.html" class="br.edu.casf.jcasf.service.student.impl.StudentServiceImpl">
        <property name="studentService" ref="studentService" />
    </bean>
    <bean id="studentService" class="br.edu.casf.jcasf.service.student.impl.StudentServiceImpl" scope="singleton" >
        <property name="connectionProviderHelper" ref="connectionProviderHelper" />
    </bean>

O que quer dizer isto:

HTTP Status 500 - 

--------------------------------------------------------------------------------

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	java.lang.Thread.run(Thread.java:619)


root cause 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/list_student.html' defined in ServletContext resource [/WEB-INF/springmvc-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'studentService' of bean class [br.edu.casf.jcasf.service.student.impl.StudentServiceImpl]: No property 'studentService' found
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	java.security.AccessController.doPrivileged(Native Method)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
	javax.servlet.GenericServlet.init(GenericServlet.java:212)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	java.lang.Thread.run(Thread.java:619)


root cause 

org.springframework.beans.InvalidPropertyException: Invalid property 'studentService' of bean class [br.edu.casf.jcasf.service.student.impl.StudentServiceImpl]: No property 'studentService' found
	org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:382)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1287)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1248)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	java.security.AccessController.doPrivileged(Native Method)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
	javax.servlet.GenericServlet.init(GenericServlet.java:212)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	java.lang.Thread.run(Thread.java:619)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.18

Ou seja. A exception diz que a propriedade "studentService" não é valida! mas é uma propriedade privada de ListStudentController com seus devidos seletor e modificador!
Se alguém puder ajudar eu agradeço! Já recompilei a aplicação, já detonei os ".class", já fiz vodu, macumba...
Já grato!
San

2 Respostas

J

Cara você fez uma auto referência:

<bean name="/list_student.html" class="br.edu.casf.jcasf.service.student.impl.StudentServiceImpl">  
    <property name="studentService" ref="studentService" />  
</bean>  
<bean id="studentService" class="br.edu.casf.jcasf.service.student.impl.StudentServiceImpl" scope="singleton" >  
    <property name="connectionProviderHelper" ref="connectionProviderHelper" />  
</bean>

“StudentServiceImpl” tem uma propriedade do tipo “StudentServiceImpl”?

M

Acho que foi este o engano! Acabei injetando a classe errada como controller!!!
Acho que estou ficando velho! E burro…
Á noite eu conserto e posto minhas desventuras!
Obrigado!
MaLSan

Criado 21 de junho de 2009
Ultima resposta 22 de jun. de 2009
Respostas 2
Participantes 2