[Resolvido] Interceptor no Vraptor3

6 respostas
katsukawa

Olá pessoal,

Acho que vocês irão ver muitos posts meus por aqui falando de VRaptor3.. :roll: :wink:

Bom.. eu sou iniciante total... mas já de cara quero logo aprender o VRaptor3!! :D Estou usando o blank-project do VRaptor3, porém eu tô seguindo a apostila Fj28 da Caelum e lá eles usam o VRaptor 2.5 eu acho. :roll:

É o seguinte, cheguei na parte que configura o interceptor no meu projeto.

Eu fiz todo o código da apostila no entanto to achando que na versão 3 do Vraptor deve ser diferente a configuração do Interceptor.
Na anotação @InterceptedBy do controller, a classe DaoInterceptor.class fica grifada de vermelho.

Segue meu controller:

package br.com.jcomputacao.vraptor.controller;

import br.com.caelum.vraptor.Resource;
import br.com.jcomputacao.vraptor.dao.Dao;
import br.com.jcomputacao.vraptor.dao.DaoFactory;
import br.com.jcomputacao.vraptor.dao.ProdutoDao;
import br.com.jcomputacao.vraptor.loja.DaoInterceptor;
import br.com.jcomputacao.vraptor.model.Produto;

import java.sql.SQLException;
import java.util.List;

import org.vraptor.annotations.InterceptedBy;

@Resource
@InterceptedBy(DaoInterceptor.class)  << A classe fica grifada de vermelho aki
public class ProdutosController {
	
	private final DaoFactory daofactory;
	
	public ProdutosController(DaoFactory daofactory) {
		this.daofactory = daofactory ;		
	}
	
	public void form () {
	}
	
	public void adiciona(Produto produto) throws SQLException {
		this.daofactory.beginTransaction();
		this.daofactory.getProdutoDao().adiciona(produto);
		this.daofactory.commit();
	}
	
	public List<Produto> lista() {
        return dao.listaTodos();
    }
}

Segue meu DaoInterceptor:

package br.com.jcomputacao.vraptor.loja;

import org.vraptor.LogicException;
import org.vraptor.LogicFlow;
import org.vraptor.annotations.Out;
import org.vraptor.view.ViewException;

import br.com.caelum.vraptor.InterceptionException;
import br.com.caelum.vraptor.core.InterceptorStack;
import br.com.caelum.vraptor.interceptor.Interceptor;
import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.SessionScoped;
import br.com.caelum.vraptor.resource.ResourceMethod;
import br.com.jcomputacao.vraptor.dao.DaoFactory;

public class DaoInterceptor implements Interceptor {
	
	private final DaoFactory factory = new DaoFactory();

	public void intercept(LogicFlow flow) throws LogicException, ViewException {
		// executa a lógica
		flow.execute();
		// se sobrou transação sem comitar, faz rollback
		if (factory.hasTransaction()) {
			factory.rollback();
		}
			factory.close();
	}
	
	@Out(key="br.com.jcomputacao.vraptor.dao.DaoFactory")	
	public DaoFactory getFactory() {
		return factory;
	}
	
	@Override
	public boolean accepts(ResourceMethod arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void intercept(InterceptorStack arg0, ResourceMethod arg1,
			Object arg2) throws InterceptionException {
		// TODO Auto-generated method stub	
	}
}

Meu DaoFactory:

package br.com.jcomputacao.vraptor.dao;

import org.hibernate.Session;
import org.hibernate.Transaction;

import br.com.jcomputacao.vraptor.model.Produto;
import br.com.jcomputacao.vraptor.util.HibernateUtil;
import br.com.jcomputacao.vraptor.dao.Dao;

public class DaoFactory {
	
	private final Session session;
	private Transaction transaction;
	
	public DaoFactory() {
		session = HibernateUtil.getSession();
	}
	
	public void beginTransaction() {
		this.transaction = this.session.beginTransaction();
	}
	
	public void commit() {
		this.transaction.commit();
		this.transaction = null;
	}
	
	public boolean hasTransaction() {
		return this.transaction != null;
	}
	
	public void rollback() {
		this.transaction.rollback();
		this.transaction = null;
	}
	
	public void close() {
		this.session.close();
	}
	
	public Dao<Produto>getProdutoDao() {
		return new Dao<Produto>(this.session, Produto.class);
	}
}

6 Respostas

Lavieri

Ou 1… ou outro… não estudo pelo velho

InterceptorDao é para fazer Injeção de Dependencia…

no VRaptor 2 a injeção é feita no interceptor
no 3 não precisa de interceptor, só anotar com @Component, o que vc quer q seja injetado, e pronto…

leia esse link todo => http://vraptor.caelum.com.br/documentacao/vraptor3.pdf

depois assista o video que tem aqui => http://vraptor.caelum.com.br/

katsukawa

Lavieri obrigado,

vou tentar e já posto pra ver se funcionou…

katsukawa

@Lavieri

Agora que você falou eu entendi melhor a lógica e ainda mais o porquê do uso do @Component... ficou claro! 8)

Eu fiz as alterações conforme vc disse, deu certo aparentemente, porém quando acesso a página /produtos/form ele dá o seguinte erro:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'produtosController' defined in file [E:\Arquivos de programas\Apache Software Foundation\Tomcat 6.0\wtpwebapps\projeto2\WEB-INF\classes\br\com\jcomputacao\vraptor\controller\ProdutosController.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [br.com.jcomputacao.vraptor.dao.DaoFactory]: : Error creating bean with name 'daoFactory' defined in file [E:\Arquivos de programas\Apache Software Foundation\Tomcat 6.0\wtpwebapps\projeto2\WEB-INF\classes\br\com\jcomputacao\vraptor\dao\DaoFactory.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.jcomputacao.vraptor.dao.DaoFactory]: Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoFactory' defined in file [E:\Arquivos de programas\Apache Software Foundation\Tomcat 6.0\wtpwebapps\projeto2\WEB-INF\classes\br\com\jcomputacao\vraptor\dao\DaoFactory.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.jcomputacao.vraptor.dao.DaoFactory]: Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:591)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:835)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
	at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:297)
	at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:942)
	at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:224)
	at br.com.caelum.vraptor.ioc.spring.VRaptorApplicationContext.getBean(VRaptorApplicationContext.java:203)
	at br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.instanceFor(SpringBasedContainer.java:61)
	at br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:41)
	at br.com.caelum.vraptor.core.InstantiatedInterceptorHandler.execute(InstantiatedInterceptorHandler.java:39)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
	at br.com.caelum.vraptor.interceptor.multipart.MultipartInterceptor.intercept(MultipartInterceptor.java:74)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:45)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
	at br.com.caelum.vraptor.interceptor.InterceptorListPriorToExecutionExtractor.intercept(InterceptorListPriorToExecutionExtractor.java:46)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:45)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
	at br.com.caelum.vraptor.core.URLParameterExtractorInterceptor.intercept(URLParameterExtractorInterceptor.java:35)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:45)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
	at br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:58)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:45)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
	at br.com.caelum.vraptor.core.DefaultRequestExecution.execute(DefaultRequestExecution.java:59)
	at br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:87)
	at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:55)
	at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:85)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Unknown Source)
        
        +400 linhas de erro + -
:shock:

Meu Controller:

package br.com.jcomputacao.vraptor.controller;

import br.com.caelum.vraptor.Resource;
import br.com.jcomputacao.vraptor.dao.DaoFactory;
import br.com.jcomputacao.vraptor.model.Produto;

import java.sql.SQLException;

@Resource
public class ProdutosController {
	
	private final DaoFactory daofactory;
	
	public ProdutosController(DaoFactory daofactory) {
		this.daofactory = daofactory ;		
	}
	
	public void form () {
	}
	
	public void adiciona(Produto produto) throws SQLException {
		this.daofactory.beginTransaction();
		this.daofactory.getProdutoDao().adiciona(produto);
		this.daofactory.commit();
	}
}

Meu DaoFactory:

package br.com.jcomputacao.vraptor.dao;

import org.hibernate.Session;
import org.hibernate.Transaction;

import br.com.caelum.vraptor.ioc.Component;
import br.com.jcomputacao.vraptor.model.Produto;
import br.com.jcomputacao.vraptor.util.HibernateUtil;
import br.com.jcomputacao.vraptor.dao.Dao;

@Component
public class DaoFactory {
	
	private final Session session;
	private Transaction transaction;
	
	public DaoFactory() {
		session = HibernateUtil.getSession();
	}
	
	public void beginTransaction() {
		this.transaction = this.session.beginTransaction();
	}
	
	public void commit() {
		this.transaction.commit();
		this.transaction = null;
	}
	
	public boolean hasTransaction() {
		return this.transaction != null;
	}
	
	public void rollback() {
		this.transaction.rollback();
		this.transaction = null;
	}
	
	public void close() {
		this.session.close();
	}
	
	public Dao<Produto>getProdutoDao() {
		return new Dao<Produto>(this.session, Produto.class);
	}
}

Meu Dao:

package br.com.jcomputacao.vraptor.dao;

import java.util.List;
import org.hibernate.Session;
import br.com.caelum.vraptor.ioc.Component;

@Component
public class Dao<T> {
	
	private final Session session;
	private final Class classe;
	
	Dao(Session session, Class classe) {
		this.session = session;
		this.classe = classe;
	}
	
	public void adiciona(T u) {
		this.session.save(u);
	}
	
	public List<T> listaTudo() {
		return this.session.createCriteria(this.classe).list();
	}
}
Lucas_Cavalcanti

Seu HibernateUtil.getSession() está soltando uma exceção… tenta ver o que é

katsukawa

Obrigado a todos!! Graças a vocês agora eu entendi boa parte do que ainda era obscuro para mim!! :smiley:

@lucascs

Era isso mesmo, eu acabei esquecendo de criar o Hibernate.cfg.xml no meu projeto. Criei e funcionou, valeu brother!! :smiley:

Agora, com meus conhecimentos já é possível desenvolver a aplicação que gostaria de desenvolver…

Novamente Obrigado! 8) :smiley:

ibotirama

Eu estou com este mesmo problema, mas o meu hibernate.cfg.xml está lá e funcionando, pois fiz classes de teste para criar o banco, inserir registros, elas funcionam perfeitamente, o meu sistema, dá o seguinte erro :

08/01/2010 14:20:37 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'equipesController' defined in file [C:\Users\PedroHenrique\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\eCampeonato\WEB-INF\classes\br\com\efacilsistemas\ecampeonato\controller\EquipesController.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [br.com.efacilsistemas.ecampeonato.dao.DaoFactory]: : Error creating bean with name 'daoFactory' defined in file [C:\Users\PedroHenrique\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\eCampeonato\WEB-INF\classes\br\com\efacilsistemas\ecampeonato\dao\DaoFactory.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.efacilsistemas.ecampeonato.dao.DaoFactory]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoFactory' defined in file [C:\Users\PedroHenrique\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\eCampeonato\WEB-INF\classes\br\com\efacilsistemas\ecampeonato\dao\DaoFactory.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.efacilsistemas.ecampeonato.dao.DaoFactory]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:591)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:835)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
	at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:297)
	at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:942)
	at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:224)
	at br.com.caelum.vraptor.ioc.spring.VRaptorApplicationContext.getBean(VRaptorApplicationContext.java:209)
	at br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.instanceFor(SpringBasedContainer.java:61)
	at br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:41)
	at br.com.caelum.vraptor.core.InstantiatedInterceptorHandler.execute(InstantiatedInterceptorHandler.java:41)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:48)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
	at br.com.caelum.vraptor.interceptor.InterceptorListPriorToExecutionExtractor.intercept(InterceptorListPriorToExecutionExtractor.java:46)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:46)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
	at br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:80)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:46)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
	at br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:67)
	at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:46)
	at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
	at br.com.caelum.vraptor.core.DefaultRequestExecution.execute(DefaultRequestExecution.java:62)
	at br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:91)
	at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:55)
	at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:88)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoFactory' defined in file [C:\Users\PedroHenrique\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\eCampeonato\WEB-INF\classes\br\com\efacilsistemas\ecampeonato\dao\DaoFactory.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.efacilsistemas.ecampeonato.dao.DaoFactory]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
	at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:622)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:584)
	... 48 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.efacilsistemas.ecampeonato.dao.DaoFactory]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
	... 62 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
	at br.com.efacilsistemas.ecampeonato.dao.DaoFactory.&lt;init&gt;(DaoFactory.java:17)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
	... 64 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Criado 20 de outubro de 2009
Ultima resposta 8 de jan. de 2010
Respostas 6
Participantes 4