Boa noite a todos!
Eu estou iniciando em VRaptor!
Como eu estou tendo muito trabalho e retrabalho com o CRUD resolvi tentar usar o Repository ao invés de Dao.
Como exemplo eu criei um projeto via vraptor scafford e copiei para minha aplicação, notei que não havia nenhum .JAR então continuo ultilizado o meus.
No código na acusa nenhum problema.
Mais quando acesso alguma URL que utiliza o repository!!!
O erro é esse:[code]HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘adminController’: Unsatisfied dependency expressed through constructor argument with index 1 of type [br.com.lojavirtual.repositories.AdminRepository]: : Error creating bean with name ‘adminRepositoryImpl’: Unsatisfied dependency expressed through constructor argument with index 0 of type [javax.persistence.EntityManager]: : No matching bean of type [javax.persistence.EntityManager] 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 [javax.persistence.EntityManager] 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.UnsatisfiedDependencyException: Error creating bean with name ‘adminRepositoryImpl’: Unsatisfied dependency expressed through constructor argument with index 0 of type [javax.persistence.EntityManager]: : No matching bean of type [javax.persistence.EntityManager] 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 [javax.persistence.EntityManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:698)
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:886)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:328)
org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:251)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1012)
br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.instanceFor(SpringBasedContainer.java:85)
br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:46)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23)
br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92)
br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)
root cause
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘adminRepositoryImpl’: Unsatisfied dependency expressed through constructor argument with index 0 of type [javax.persistence.EntityManager]: : No matching bean of type [javax.persistence.EntityManager] 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 [javax.persistence.EntityManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:698)
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:886)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:328)
org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:820)
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:762)
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:680)
org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:771)
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:691)
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:886)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:328)
org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:251)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1012)
br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.instanceFor(SpringBasedContainer.java:85)
br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:46)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23)
br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92)
br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)
root cause
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.persistence.EntityManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:896)
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:765)
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:680)
org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:771)
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:691)
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:886)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:328)
org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:820)
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:762)
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:680)
org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:771)
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:691)
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:886)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:328)
org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:251)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1012)
br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.instanceFor(SpringBasedContainer.java:85)
br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:46)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23)
br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92)
br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.0 logs.
Apache Tomcat/7.0.0[/code]
Não utilizei a configuração persistence.xml porque eu não sei fazer e pq queria deixa quase como antes <persistence xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
−
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
−
<properties>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.url" value="jdbc:hsqldb:file:tmp/devdb"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.query.substitutions" value="true=1, false=0"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
Estou usando as dependencias do Spring
[code]
<?xml version="1.0" encoding="UTF-8"?>
<tx:annotation-driven />
classpath:/hibernate.cfg.xml
[/code]
[code]
<?xml version='1.0' encoding='utf-8'?>
com.mysql.jdbc.Driver
jdbc:mysql://localhost/lojavirtual
root
true
true
org.hibernate.dialect.MySQL5InnoDBDialect
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- entidades -->
<mapping class="br.com.lojavirtual.models.Admin" />
<mapping class="br.com.lojavirtual.models.Produto" />
<mapping class="br.com.lojavirtual.models.Cliente" />
<mapping class="br.com.lojavirtual.models.Categoria" />
<mapping class="br.com.lojavirtual.models.Comentario" />
</session-factory>
[/code]
olá amigo,
Ao que parece é que a injeção de dependencia está com problemas.
o Spring não consegue injetar a classe devido um outro objeto que nao está sendo injetado nesse seu repositorio e ao que parece é o EntityManager
Se vc debugar o código vc vai ver que vc deve ter esquecido de anotar algum objeto ou algum objeto estrá dando exception ao ser instanciado pelo spring e por isso nao se completa a injeção em cadeia
Não conheço o vRaptor mas eu entendi isso na mensagem da Exceprion
Espero ter ajudado
Fallow
vc está usando hibernate direto ou JPA?
Estou e quero continuar usando o Hibernate
então vc não precisa do persistence.xml, e não deveria receber EntityManager nas classes (o erro aconteceu exatamente por isso)
Meu repositório está assim:[code]package br.com.lojavirtual.repositories;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
public abstract class Repositorio<T, I extends Serializable> {
protected final EntityManager gerenteDeEntidade;
protected final Class<T> clazz;
protected Repositorio(EntityManager entityManager) {
this.gerenteDeEntidade = entityManager;
@SuppressWarnings("unchecked")
Class<T> clazz = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
this.clazz = clazz;
}
public void criar(T entity) {
gerenteDeEntidade.persist(entity);
}
public void atualizar(T entity) {
gerenteDeEntidade.merge(entity);
}
public void destruir(T entity) {
gerenteDeEntidade.remove(entity);
}
public T carrega(I id) {
return gerenteDeEntidade.find(clazz, id);
}
public void recarrega(T entity) {
gerenteDeEntidade.refresh(entity);
}
public List<T> listaTudo() {
Query query = gerenteDeEntidade.createQuery("from " + clazz.getName());
@SuppressWarnings("unchecked")
List<T> resultList = query.getResultList();
return resultList;
}
}[/code]
Alguém pode ajudar? Eu quero usar com Hibernate!
só receber Session ao invés de EntityManager, e usar os respectivos métodos
Eu fiz assim:[code]package br.com.lojavirtual.repositories;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.util.List;
import org.hibernate.Session;
import org.springframework.transaction.annotation.Transactional;
public abstract class Repositorio<T, I extends Serializable> {
protected final Class<T> clazz;
private final Session session;
protected Repositorio(Session session) {
this.session = session;
@SuppressWarnings("unchecked")
Class<T> clazz = (Class<T>) ((ParameterizedType) getClass()
.getGenericSuperclass()).getActualTypeArguments()[0];
this.clazz = clazz;
}
@Transactional
public void salva(T produto) {
session.save(produto);
}
@Transactional
public void atualiza(T entity) {
session.update(entity);
}
@Transactional
public void remove(T produto) {
session.delete(produto);
}
@SuppressWarnings("unchecked")
public T carrega(I id) {
return (T) this.session.load(clazz, id);
}
public void recarrega(T entity) {
session.refresh(entity);
}
@SuppressWarnings("unchecked")
public List<T> listaTudo() {
return this.session.createCriteria(clazz).list();
}
}[/code]
Vou testar aqui!
Funcionou!
Mais agora deu uma duvida:
Tenho duas URL’s @Get("/admins/new")
public Admin newAdmin() {
return new Admin();
}
// e
@Get("/admins/{admin.login}")
public Admin show(Admin admin) {
return repository.localiza(admin);
}
Bom o sistema está dizendo que são iguais!
java.lang.IllegalStateException: There are two rules that matches the uri '/admins/new'
with method GET: [[FixedMethodStrategy: /admins/new
AdminController.newAdmin()
[GET]], [FixedMethodStrategy: /admins/{admin.login}
AdminController.show(Admin)
[GET]]] with same priority. Consider using @Path priority attribute.
br.com.caelum.vraptor.http.route.DefaultRouter.checkIfThereIsAnotherRoute(DefaultRouter.java:96)
br.com.caelum.vraptor.http.route.DefaultRouter.parse(DefaultRouter.java:87)
br.com.caelum.vraptor.http.DefaultResourceTranslator.translate(DefaultResourceTranslator.java:59)
br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:66)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23)
br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92)
br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)
Lucas!
Fiz isso para funcionar! Alterei aqui onde está o comentário.
[code]
// Antes era assim:
//@Get("/admins/new")
@Get
@Path("/admins/new")
public Admin newAdmin() {
return new Admin();
}
@Put("/admins")
public void update(Admin admin) {
validator.validate(admin);
validator.onErrorUsePageOf(this).edit(admin);
repository.atualiza(admin);
result.redirectTo(this).index();
}
@Post("/admins/{admin.login}/edit")
public Admin edit(Admin admin) {
return repository.localiza(admin);
}
@Get("/admins/{admin.login}")
public Admin show(Admin admin) {
return repository.localiza(admin);
}
@Delete("/admins/{admin.login}")
public void destroy(Admin admin) {
repository.remove(repository.localiza(admin));
result.redirectTo(this).index();
}[/code]
jefferson, faça isso:
@Get("/admins/new")
public Admin newAdmin() {
return new Admin();
}
// e
@Get @Path(value ="/admins/{admin.login}", priority=Path.LOWEST)
public Admin show(Admin admin) {
return repository.localiza(admin);
}
assim o vraptor vai testar a url do /new antes, e não vai dar exception
Lucas, só funcionou assim:
[code] @Get @Path(value = “/admins/new”, priority=Path.DEFAULT)
public Admin newAdmin() {
return new Admin();
}
@Put("/admins")
public void update(Admin admin) {
validator.validate(admin);
validator.onErrorUsePageOf(this).edit(admin);
repository.atualiza(admin);
result.redirectTo(this).index();
}
@Get("/admins/{admin.login}/edit")
public Admin edit(Admin admin) {
return repository.busca(admin);
}
@Get @Path(value ="/admins/{admin.login}", priority=Path.LOWEST)
public Admin show(Admin admin) {
return repository.busca(admin);
}[/code]
Vc teria um exemplo de INNER JOIN com o repositoty e Hibernate?
ex: Categoria [1] --------------------- [*] Produto [1] ------------------------- [1…5] Imagem
se vc estiver com a versão 3.3.1, se eu não me engano vc não precisa colocar o priority no newAdmin…
e se eu estiver enganado, trocar @Get("/admins/new") para @Get @Path("/admins/new") já funcionaria
PS: abre outro tópico para essa dúvida do inner join
Lucas o meu ainda é a versão 3.3.0, vou atualizar hoje!
Lucas eu perdi meu tempo ,
porque não tive sucesso após a atualização!
De:org.springframework.aop-3.0.0.RELEASE.jar
org.springframework.asm-3.0.0.RELEASE.jar
org.springframework.aspects-3.0.0.RELEASE.jar
org.springframework.beans-3.0.0.RELEASE.jar
org.springframework.context-3.0.0.RELEASE.jar
org.springframework.core-3.0.0.RELEASE.jar
org.springframework.expression-3.0.0.RELEASE.jar
org.springframework.jdbc-3.0.5.RELEASE.jar
org.springframework.orm-3.0.5.RELEASE.jar
org.springframework.transaction-3.0.5.RELEASE.jar
org.springframework.web-3.0.0.RELEASE.jar
vraptor-3.3.0.jar
Para:org.springframework.aop-3.0.5.RELEASE.jar
org.springframework.asm-3.0.5.RELEASE.jar
org.springframework.aspects-3.0.5.RELEASE.jar
org.springframework.beans-3.0.5.RELEASE.jar
org.springframework.context-3.0.5.RELEASE.jar
org.springframework.core-3.0.5.RELEASE.jar
org.springframework.expression-3.0.5.RELEASE.jar
org.springframework.jdbc-3.0.5.RELEASE.jar
org.springframework.orm-3.0.5.RELEASE.jar
org.springframework.transaction-3.0.5.RELEASE.jar
org.springframework.web-3.0.5.RELEASE.jar
vraptor-3.3.1.jar
Ou falta alguma coisa?
Eu não sei mais o que fazer!!!
Está aparecendo esse erro no form!
Controller
@Get @Path("/comentarios/new")
public Comentario newComentario() {
return new Comentario();
}
form.jsp
[code]<c:if test="${not empty errors}">
<c:forEach items="${errors}" var=“error”>
${error.category} - ${error.message}
</c:forEach>
</c:if>
<c:if test="${not empty comentario.id}">
<input type="hidden" name="comentario.id" value="${comentario.id}"/>
<input type="hidden" name="comentario.idProduto" value="${comentario.idProduto}"/>
<input type="hidden" name="_method" value="put"/>
</c:if>
<div class="field">
Data:<br />
<input type="text" name="comentario.data" value="${comentario.data}"/>
</div>
<div class="field">
Comentario:<br />
<input type="text" name="comentario.comentario" value="${comentario.comentario}"/>
</div>
<div class="field">
Avaliacaomedia:<br />
<input type="text" name="comentario.avaliacaoMedia" value="${comentario.avaliacaoMedia}"/>
</div>
<div class="field">
Titulo:<br />
<input type="text" name="comentario.titulo" value="${comentario.titulo}"/>
</div>
<div class="field">
Qualidade:<br />
<input type="text" name="comentario.qualidade" value="${comentario.qualidade}"/>
</div>
<div class="field">
Facilidade:<br />
<input type="text" name="comentario.facilidade" value="${comentario.facilidade}"/>
</div>
<div class="field">
Nometitular:<br />
<input type="text" name="comentario.nomeTitular" value="${comentario.nomeTitular}"/>
</div>
<div class="field">
Custobeneficio:<br />
<input type="text" name="comentario.custoBeneficio" value="${comentario.custoBeneficio}"/>
</div>
send
Back
[/code]
Erro
[code]HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
br.com.caelum.vraptor.view.ResultException: org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/comentario/form.jsp at line 25
22:
23:
24: Avaliacaomedia:
25:
26:
27:
28: Titulo:
Stacktrace:
br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:69)
br.com.caelum.vraptor.interceptor.ForwardToDefaultViewInterceptor.intercept(ForwardToDefaultViewInterceptor.java:60)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.OutjectResult.intercept(OutjectResult.java:67)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:59)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:85)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:83)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:48)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:71)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23)
br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92)
br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)
root cause
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/comentario/form.jsp at line 25
22:
23:
24: Avaliacaomedia:
25:
26:
27:
28: Titulo:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:517)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:427)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
br.com.caelum.vraptor.core.DefaultStaticContentHandler.deferProcessingToContainer(DefaultStaticContentHandler.java:64)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:80)
br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:67)
br.com.caelum.vraptor.interceptor.ForwardToDefaultViewInterceptor.intercept(ForwardToDefaultViewInterceptor.java:60)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.OutjectResult.intercept(OutjectResult.java:67)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:59)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:85)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:83)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:48)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:71)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23)
br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92)
br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)
root cause
javax.el.PropertyNotFoundException: Property ‘avaliacaoMedia’ not found on type br.com.jefferson.blank.models.Comentario
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:200)
javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:177)
javax.el.BeanELResolver.property(BeanELResolver.java:287)
javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:55)
org.apache.el.parser.AstValue.getValue(AstValue.java:168)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:971)
org.apache.jsp.WEB_002dINF.jsp.comentario.newComentario_jsp._jspService(newComentario_jsp.java:114)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:73)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:378)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
br.com.caelum.vraptor.core.DefaultStaticContentHandler.deferProcessingToContainer(DefaultStaticContentHandler.java:64)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:80)
br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:67)
br.com.caelum.vraptor.interceptor.ForwardToDefaultViewInterceptor.intercept(ForwardToDefaultViewInterceptor.java:60)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.OutjectResult.intercept(OutjectResult.java:67)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:59)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:85)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:83)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:48)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:71)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:23)
br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:92)
br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:89)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.0 logs.
Apache Tomcat/7.0.0[/code]
Está resolvido!
Eu já havia vasculhado tudo, quando eu praticamente tinha desistido, eu deletei todos os get’s/set’s e gerei novamente.
E pronto! Funcionou, mais agora não sei porque estava dando erro?
Mais o importânte é que deu certo! Obrigado á todos que ajudaram, eu a quem estiver lendo isso não desista nunca!
se vc ler a exception completa:
root cause
javax.el.PropertyNotFoundException: Property 'avaliacaoMedia' not found on type br.com.jefferson.blank.models.Comentario
ou seja, não existia o getAvaliacaoMedia na classe Comentario
OI Lucas,
O código foi gerado pelo vraptor scalfford!
Exitia sim, antes de regera-los (get e set) eu conferi, mais de alguma isso não era encontrado!
Mais está tudo certo agora!