Olá à todos,
Estou tendo um problema ao relacionar duas tabelas. E esse erro começou aparecer agora, em outras tabelas isso não aparece. Meu ambiente é: Wildfly 10.0, spring-data-jpa.
Estou usando classes para configurar o ambiente, não uso arquivo xml. Tenho outras classes que estão definidas da mesma forma e o erro não acontece
Minhas classes são: (não coloquei os getters e setter para não ficar muito grande)
@Entity
@Table(name = “tipoitemconfig”)
@DynamicUpdate
public class TipoItemConfig implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotBlank(message = "O nome do tipo de item de configuração é obrigatório")
@Size(max = 60)
private String nome;
private boolean ativo;
@OneToMany(mappedBy = "tipoitemconfig", targetEntity = ItemConfig.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<ItemConfig> itemConfigList;
}
@Entity
@Table(name = “itemconfig”)
@DynamicUpdate
public class ItemConfig implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotBlank(message = "O nome é obrigatório")
@Size(max = 60)
private String nome;
private boolean ativo;
@ManyToOne
@JoinColumn(name="tipoitemconfig_id")
private TipoItemConfig tipoItemConfig;
}
O erro é esse:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in br.com.hmanager.config.JPAConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:220)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1018)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:988)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:579)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:546)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:707)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:680)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:354)
… 51 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
… 68 more
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:774)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:724)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:54)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1621)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1589)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:848)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:876)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362)
at br.com.hmanager.config.JPAConfig.entityManagerFactory(JPAConfig.java:52)
at br.com.hmanager.config.JPAConfig$$EnhancerBySpringCGLIB$$2f91ed7a.CGLIB$entityManagerFactory$3()
at br.com.hmanager.config.JPAConfig$$EnhancerBySpringCGLIB$$2f91ed7a$$FastClassBySpringCGLIB$$f42b741f.invoke()
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
at br.com.hmanager.config.JPAConfig$$EnhancerBySpringCGLIB$$2f91ed7a.entityManagerFactory()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
… 69 more
13:17:07,858 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) WFLYCTL0013: Operation (“deploy”) failed - address: ([(“deployment” => “hmanager.war”)]) - failure description: {“WFLYCTL0080: Failed services” => {“jboss.undertow.deployment.default-server.default-host./hmanager” => “org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./hmanager: java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘securityConfig’: Unsatisfied dependency expressed through field ‘userDetailsService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘appUserDetailsService’: Unsatisfied dependency expressed through field ‘usuarios’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘usuariosImpl’: Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in br.com.hmanager.config.JPAConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘securityConfig’: Unsatisfied dependency expressed through field ‘userDetailsService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘appUserDetailsService’: Unsatisfied dependency expressed through field ‘usuarios’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘usuariosImpl’: Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in br.com.hmanager.config.JPAConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘securityConfig’: Unsatisfied dependency expressed through field ‘userDetailsService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘appUserDetailsService’: Unsatisfied dependency expressed through field ‘usuarios’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘usuariosImpl’: Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in br.com.hmanager.config.JPAConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘appUserDetailsService’: Unsatisfied dependency expressed through field ‘usuarios’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘usuariosImpl’: Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in br.com.hmanager.config.JPAConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘usuariosImpl’: Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in br.com.hmanager.config.JPAConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in br.com.hmanager.config.JPAConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList”}}
13:17:07,987 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0010: Deployed “hmanager.war” (runtime-name : “hmanager.war”)
13:17:07,988 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.undertow.deployment.default-server.default-host./hmanager: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./hmanager: java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘securityConfig’: Unsatisfied dependency expressed through field ‘userDetailsService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘appUserDetailsService’: Unsatisfied dependency expressed through field ‘usuarios’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘usuariosImpl’: Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in br.com.hmanager.config.JPAConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method ‘entityManagerFactory’ threw exception; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.hmanager.model.ItemConfig.tipoitemconfig in br.com.hmanager.model.TipoItemConfig.itemConfigList
Obrigado pela ajuda