Bom dia pessoal!
Ao tentar cadastrar um representante, estou recebendo o erro no browser:
HTTP Status 500 - org.hibernate.PersistentObjectException: detached entity passed to persist: br.com.ebf.modelo.Representante
type Exception report
message org.hibernate.PersistentObjectException: detached entity passed to persist: br.com.ebf.modelo.Representante
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: br.com.ebf.modelo.Representante
org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1608)
org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1152)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:40)
org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100)
org.jboss.weld.proxies.EntityManager$1262842486$Proxy$_$$_WeldClientProxy.persist(Unknown Source)
br.com.ebf.dao.RepresentanteDao.adiciona(RepresentanteDao.java:28)
br.com.ebf.dao.RepresentanteDao$Proxy$_$$_WeldClientProxy.adiciona(Unknown Source)
br.com.ebf.controller.RepresentanteController.adiciona(RepresentanteController.java:39)
br.com.ebf.controller.RepresentanteController$Proxy$_$$_WeldClientProxy.adiciona(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
net.vidageek.mirror.provider.java.PureJavaMethodReflectionProvider.invoke(PureJavaMethodReflectionProvider.java:38)
net.vidageek.mirror.invoke.MethodHandlerByMethod.withArgs(MethodHandlerByMethod.java:54)
br.com.caelum.vraptor.core.DefaultReflectionProvider.invoke(DefaultReflectionProvider.java:42)
br.com.caelum.vraptor.core.DefaultReflectionProvider$Proxy$_$$_WeldClientProxy.invoke(Unknown Source)
br.com.caelum.vraptor.observer.ExecuteMethod$1.call(ExecuteMethod.java:82)
br.com.caelum.vraptor.observer.ExecuteMethod$1.call(ExecuteMethod.java:72)
br.com.caelum.vraptor.core.Try.run(Try.java:18)
br.com.caelum.vraptor.observer.ExecuteMethod.execute(ExecuteMethod.java:72)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266)
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232)
org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169)
org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:165)
org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:119)
org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:112)
org.jboss.weld.event.EventImpl.fire(EventImpl.java:83)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:78)
br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:98)
br.com.caelum.vraptor.interceptor.FlashInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:71)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:68)
br.com.caelum.vraptor.core.Try.run(Try.java:18)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.executeSafely(ToInstantiateInterceptorHandler.java:68)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:75)
br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:71)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:68)
br.com.caelum.vraptor.core.Try.run(Try.java:18)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.executeSafely(ToInstantiateInterceptorHandler.java:68)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
br.com.caelum.vraptor.core.DefaultInterceptorStack.start(DefaultInterceptorStack.java:93)
br.com.caelum.vraptor.core.DefaultInterceptorStack$Proxy$_$$_WeldClientProxy.start(Unknown Source)
br.com.caelum.vraptor.observer.RequestHandlerObserver.handle(RequestHandlerObserver.java:93)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266)
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232)
org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169)
org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:165)
org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:119)
org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:112)
org.jboss.weld.event.EventImpl.fire(EventImpl.java:83)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:123)
root cause
org.hibernate.PersistentObjectException: detached entity passed to persist: br.com.ebf.modelo.Representante
org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:124)
org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58)
org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:778)
org.hibernate.internal.SessionImpl.persist(SessionImpl.java:751)
org.hibernate.internal.SessionImpl.persist(SessionImpl.java:756)
org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1146)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:40)
org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100)
org.jboss.weld.proxies.EntityManager$1262842486$Proxy$_$$_WeldClientProxy.persist(Unknown Source)
br.com.ebf.dao.RepresentanteDao.adiciona(RepresentanteDao.java:28)
br.com.ebf.dao.RepresentanteDao$Proxy$_$$_WeldClientProxy.adiciona(Unknown Source)
br.com.ebf.controller.RepresentanteController.adiciona(RepresentanteController.java:39)
br.com.ebf.controller.RepresentanteController$Proxy$_$$_WeldClientProxy.adiciona(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
net.vidageek.mirror.provider.java.PureJavaMethodReflectionProvider.invoke(PureJavaMethodReflectionProvider.java:38)
net.vidageek.mirror.invoke.MethodHandlerByMethod.withArgs(MethodHandlerByMethod.java:54)
br.com.caelum.vraptor.core.DefaultReflectionProvider.invoke(DefaultReflectionProvider.java:42)
br.com.caelum.vraptor.core.DefaultReflectionProvider$Proxy$_$$_WeldClientProxy.invoke(Unknown Source)
br.com.caelum.vraptor.observer.ExecuteMethod$1.call(ExecuteMethod.java:82)
br.com.caelum.vraptor.observer.ExecuteMethod$1.call(ExecuteMethod.java:72)
br.com.caelum.vraptor.core.Try.run(Try.java:18)
br.com.caelum.vraptor.observer.ExecuteMethod.execute(ExecuteMethod.java:72)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266)
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232)
org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169)
org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:165)
org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:119)
org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:112)
org.jboss.weld.event.EventImpl.fire(EventImpl.java:83)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:78)
br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:98)
br.com.caelum.vraptor.interceptor.FlashInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:71)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:68)
br.com.caelum.vraptor.core.Try.run(Try.java:18)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.executeSafely(ToInstantiateInterceptorHandler.java:68)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:75)
br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:71)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler$1.call(ToInstantiateInterceptorHandler.java:68)
br.com.caelum.vraptor.core.Try.run(Try.java:18)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.executeSafely(ToInstantiateInterceptorHandler.java:68)
br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:61)
br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
br.com.caelum.vraptor.core.DefaultInterceptorStack.start(DefaultInterceptorStack.java:93)
br.com.caelum.vraptor.core.DefaultInterceptorStack$Proxy$_$$_WeldClientProxy.start(Unknown Source)
br.com.caelum.vraptor.observer.RequestHandlerObserver.handle(RequestHandlerObserver.java:93)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266)
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232)
org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169)
org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:165)
org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:119)
org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:112)
org.jboss.weld.event.EventImpl.fire(EventImpl.java:83)
br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:123)
note The full stack trace of the root cause is available in the Apache Tomcat/8.5.8 logs.
Apache Tomcat/8.5.8