Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Erro na anotação @Transaction - Spring MVC

Estou recebendo erro ao anotar a classe com @Transaction:

Estou usando o WildFly com Postgres para Spring MVC, o código está igual ao do curso:

https://s3.amazonaws.com/caelum-online-public/spring-mvc-1-criando-aplicacoes-web/springmvc1-aula3.zip

15:48:33,915 WARN  [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (ServerService Thread Pool -- 121) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'produtosController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private br.com.daos.ProdutoDAO br.com.controller.ProdutosController.produtoDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'produtoDAO' defined in "/home/notebook-n/wildfly-20.0.1.Final/standalone/deployments/cursoSpring.war/WEB-INF/classes/br/com/daos/ProdutoDAO.class": Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class br.com.daos.ProdutoDAO]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private br.com.daos.ProdutoDAO br.com.controller.ProdutosController.produtoDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'produtoDAO' defined in "/home/notebook-n/wildfly-20.0.1.Final/standalone/deployments/cursoSpring.war/WEB-INF/classes/br/com/daos/ProdutoDAO.class": Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class br.com.daos.ProdutoDAO]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'produtoDAO' defined in "/home/notebook-n/wildfly-20.0.1.Final/standalone/deployments/cursoSpring.war/WEB-INF/classes/br/com/daos/ProdutoDAO.class": Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class br.com.daos.ProdutoDAO]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null

Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class br.com.daos.ProdutoDAO]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null

Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null

Caused by: java.lang.LinkageError: loader (instance of org/jboss/modules/ModuleClassLoader): attempted duplicate class definition for name: "br/com/daos/ProdutoDAO$$EnhancerBySpringCGLIB$$1077e15a"

2 respostas

Oi Matias

O projeto do curso está configurado para conectar no MySQL, você chegou a configurar o JPAConfiguration com o driver do Postgres?

solução!

Configurei sim, acho que o problema é conflito de bibliotecas, o WildFly já vem com várias bibliotecas. Estou verificando

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software