[RESOLVIDO] Migrando de DAO para Repository

Oe jehffersson,
me explica uma coisa, quando vc vai injetar o “Repositorio” no seu controller, vc faz isso por meio do construtor mesmo? Outra duvida, o Repositorio não é abstract? Vc tem uma instancia dele? Como vc fez? Pode mostrar?

valeu

Lucas no meu caso, tenho JPA, mas tenho o mesmo problema. Preciso configurar algo mais no persistent.xml.

qual problema exatamente, Carlos?

Estou convertendo os meus DAOs para Generics e Repository em um projeto utilizando VRaptor e JPA. Mas tem algum problema com a injeção de dependência que não encontro.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘usuarioController’: Unsatisfied dependency expressed through constructor argument with index 0 of type [br.com.tetrawebtrack.repository.UsuarioRepository]: : No matching bean of type [br.com.tetrawebtrack.repository.UsuarioRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [br.com.tetrawebtrack.repository.UsuarioRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

[java]
package br.com.tetrawebtrack.controller;

import java.util.List;

import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Resource;
import br.com.tetrawebtrack.annotation.Permissao;
import br.com.tetrawebtrack.modelo.Perfil;
import br.com.tetrawebtrack.modelo.Usuario;
import br.com.tetrawebtrack.repository.UsuarioRepository;

@Resource
@Permissao({Perfil.ADMINISTRADOR, Perfil.GESTOR})
public class UsuarioController {

private final UsuarioRepository repository;

public UsuarioController(UsuarioRepository repository) {
	this.repository = repository;
}

@Get("/cadastro/usuario/lista")
public List<Usuario> lista() {
	//result.include("entityList", repository.all());
	return (List<Usuario>) repository.all();
}

}
[/java]

existe algum UsuarioRepository anotado com @Component?

Realmente o GenericBusiness não era um componente do VRaptor. Valeu obrigado, no inicio do estudo tem coisa que passa na cara e não é notada.

Alguém poderia me ajudar com esse erro:

Estou criando um exemplo simples com Spring, para entender melhor funcionamento do Spring.

GRAVE: Error Rendering View[/content/categoria.xhtml] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'categoriaBean' defined in file [C:\Desenvolvimento\Apache Tomcat 7.0.12\wtpwebapps\ExemploBasicoSpring\WEB-INF\classes\br\com\exemplospring\controller\CategoriaBean.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [br.com.exemplospring.service.CategoriaService]: : No matching bean of type [br.com.exemplospring.service.CategoriaService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [br.com.exemplospring.service.CategoriaService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:715) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:195) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:329) at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43) at org.springframework.web.context.request.SessionScope.get(SessionScope.java:92) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1045) at org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:56) at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:71) at org.apache.el.parser.AstValue.getValue(AstValue.java:147) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:181) at javax.faces.component.UIOutput.getValue(UIOutput.java:169) at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:883) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312) at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185) at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:853) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652) at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:853) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:509) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [br.com.exemplospring.service.CategoriaService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:903) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:772) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:686) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:788) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:708) ... 56 more 13/04/2012 13:29:42 org.apache.catalina.core.StandardWrapperValve invoke GRAVE: Servlet.service() for servlet [Faces Servlet] in context with path [/ExemploBasicoSpring] threw exception [Error creating bean with name 'categoriaBean' defined in file [C:\Desenvolvimento\Apache Tomcat 7.0.12\wtpwebapps\ExemploBasicoSpring\WEB-INF\classes\br\com\exemplospring\controller\CategoriaBean.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [br.com.exemplospring.service.CategoriaService]: : No matching bean of type [br.com.exemplospring.service.CategoriaService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [br.com.exemplospring.service.CategoriaService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}] with root cause org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [br.com.exemplospring.service.CategoriaService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:903) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:772) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:686) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:788) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:708) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:195) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:329) at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43) at org.springframework.web.context.request.SessionScope.get(SessionScope.java:92) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1045) at org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:56) at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:71) at org.apache.el.parser.AstValue.getValue(AstValue.java:147) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:181) at javax.faces.component.UIOutput.getValue(UIOutput.java:169) at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:883) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312) at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185) at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:853) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652) at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:853) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:509) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

NoSuchBeanDefinitionException: No matching bean of type [br.com.exemplospring.service.CategoriaService]

não existe nenhum componente registrado com essa interface/classe… falta algum @Component