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

Cache de segundo nível e versionamento com VRaptor

Ao habilitar a anotação @Cache começa a dar uma exception atrás da outra.

Ao habilitar @Version o banco de dados esta criando novos registros toda hora ao atualizar um registro.

8 respostas

Oi Matheus,

Sobre o Cache: Qual é a exceção que dá? Onde vc está usando @Cache (entity ou collection)?

Sobre @Version: aqui também preciso de mais detalhe para ajudar.

abs

Estou usando em Entity:

@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)

br.com.caelum.vraptor.InterceptionException: java.lang.ExceptionInInitializerError
    br.com.caelum.vraptor.interceptor.StepInvoker.invokeMethod(StepInvoker.java:54)
    br.com.caelum.vraptor.interceptor.StepInvoker.tryToInvoke(StepInvoker.java:40)
    br.com.caelum.vraptor.interceptor.StepInvoker$Proxy$_$$_WeldClientProxy.tryToInvoke(Unknown Source)
    br.com.caelum.vraptor.interceptor.InterceptorExecutor.execute(InterceptorExecutor.java:63)
    br.com.caelum.vraptor.interceptor.InterceptorExecutor$Proxy$_$$_WeldClientProxy.execute(Unknown Source)
    br.com.caelum.vraptor.interceptor.AspectStyleInterceptorHandler.execute(AspectStyleInterceptorHandler.java:84)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    br.com.caelum.brutauth.interceptors.BrutauthMapInterceptor.intercept(BrutauthMapInterceptor.java:36)
    br.com.caelum.brutauth.interceptors.BrutauthMapInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:58)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    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.execute(ToInstantiateInterceptorHandler.java:58)
    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(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    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:118)
root cause

java.lang.ExceptionInInitializerError
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:110)
    org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallbacks(ConstructorInjectionPoint.java:84)
    org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:71)
    org.jboss.weld.injection.producer.AbstractInstantiator.newInstance(AbstractInstantiator.java:28)
    org.jboss.weld.injection.producer.BasicInjectionTarget.produce(BasicInjectionTarget.java:85)
    org.jboss.weld.injection.producer.BeanInjectionTarget.produce(BeanInjectionTarget.java:183)
    org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:149)
    org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
    org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:733)
    org.jboss.weld.injection.producer.AbstractMemberProducer.getReceiver(AbstractMemberProducer.java:128)
    org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:148)
    org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:183)
    org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
    org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:98)
    org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:99)
    org.jboss.weld.proxies.EntityManager$1722484474$Proxy$_$$_WeldClientProxy.getTransaction(Unknown Source)
    br.com.hebi.interceptor.EntityManagerInterceptor.before(EntityManagerInterceptor.java:23)
    br.com.hebi.interceptor.EntityManagerInterceptor$Proxy$_$$_WeldClientProxy.before(Unknown Source)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    net.vidageek.mirror.provider.java.PureJavaMethodReflectionProvider.invoke(PureJavaMethodReflectionProvider.java:38)
    net.vidageek.mirror.invoke.MethodHandlerByMethod.withArgs(MethodHandlerByMethod.java:54)
    br.com.caelum.vraptor.interceptor.StepInvoker.invokeMethod(StepInvoker.java:49)
    br.com.caelum.vraptor.interceptor.StepInvoker.tryToInvoke(StepInvoker.java:40)
    br.com.caelum.vraptor.interceptor.StepInvoker$Proxy$_$$_WeldClientProxy.tryToInvoke(Unknown Source)
    br.com.caelum.vraptor.interceptor.InterceptorExecutor.execute(InterceptorExecutor.java:63)
    br.com.caelum.vraptor.interceptor.InterceptorExecutor$Proxy$_$$_WeldClientProxy.execute(Unknown Source)
    br.com.caelum.vraptor.interceptor.AspectStyleInterceptorHandler.execute(AspectStyleInterceptorHandler.java:84)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    br.com.caelum.brutauth.interceptors.BrutauthMapInterceptor.intercept(BrutauthMapInterceptor.java:36)
    br.com.caelum.brutauth.interceptors.BrutauthMapInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:58)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    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.execute(ToInstantiateInterceptorHandler.java:58)
    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(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    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:118)
root cause

javax.persistence.PersistenceException: Unable to build entity manager factory
    org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:83)
    org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
    javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    br.com.hebi.producer.EntityManagerProducer.<clinit>(EntityManagerProducer.java:14)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:110)
    org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallbacks(ConstructorInjectionPoint.java:84)
    org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:71)
    org.jboss.weld.injection.producer.AbstractInstantiator.newInstance(AbstractInstantiator.java:28)
    org.jboss.weld.injection.producer.BasicInjectionTarget.produce(BasicInjectionTarget.java:85)
    org.jboss.weld.injection.producer.BeanInjectionTarget.produce(BeanInjectionTarget.java:183)
    org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:149)
    org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
    org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:733)
    org.jboss.weld.injection.producer.AbstractMemberProducer.getReceiver(AbstractMemberProducer.java:128)
    org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:148)
    org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:183)
    org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
    org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:98)
    org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:99)
    org.jboss.weld.proxies.EntityManager$1722484474$Proxy$_$$_WeldClientProxy.getTransaction(Unknown Source)
    br.com.hebi.interceptor.EntityManagerInterceptor.before(EntityManagerInterceptor.java:23)
    br.com.hebi.interceptor.EntityManagerInterceptor$Proxy$_$$_WeldClientProxy.before(Unknown Source)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    net.vidageek.mirror.provider.java.PureJavaMethodReflectionProvider.invoke(PureJavaMethodReflectionProvider.java:38)
    net.vidageek.mirror.invoke.MethodHandlerByMethod.withArgs(MethodHandlerByMethod.java:54)
    br.com.caelum.vraptor.interceptor.StepInvoker.invokeMethod(StepInvoker.java:49)
    br.com.caelum.vraptor.interceptor.StepInvoker.tryToInvoke(StepInvoker.java:40)
    br.com.caelum.vraptor.interceptor.StepInvoker$Proxy$_$$_WeldClientProxy.tryToInvoke(Unknown Source)
    br.com.caelum.vraptor.interceptor.InterceptorExecutor.execute(InterceptorExecutor.java:63)
    br.com.caelum.vraptor.interceptor.InterceptorExecutor$Proxy$_$$_WeldClientProxy.execute(Unknown Source)
    br.com.caelum.vraptor.interceptor.AspectStyleInterceptorHandler.execute(AspectStyleInterceptorHandler.java:84)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    br.com.caelum.brutauth.interceptors.BrutauthMapInterceptor.intercept(BrutauthMapInterceptor.java:36)
    br.com.caelum.brutauth.interceptors.BrutauthMapInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:58)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    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.execute(ToInstantiateInterceptorHandler.java:58)
    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(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    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:118)
root cause

org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
    org.hibernate.cache.internal.NoCachingRegionFactory.buildEntityRegion(NoCachingRegionFactory.java:83)
    org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:364)
    org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)
    org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
    org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843)
    org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)
    org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842)
    org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:75)
    org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
    javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    br.com.hebi.producer.EntityManagerProducer.<clinit>(EntityManagerProducer.java:14)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:110)
    org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallbacks(ConstructorInjectionPoint.java:84)
    org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:71)
    org.jboss.weld.injection.producer.AbstractInstantiator.newInstance(AbstractInstantiator.java:28)
    org.jboss.weld.injection.producer.BasicInjectionTarget.produce(BasicInjectionTarget.java:85)
    org.jboss.weld.injection.producer.BeanInjectionTarget.produce(BeanInjectionTarget.java:183)
    org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:149)
    org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
    org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:733)
    org.jboss.weld.injection.producer.AbstractMemberProducer.getReceiver(AbstractMemberProducer.java:128)
    org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:148)
    org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:183)
    org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
    org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:98)
    org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:99)
    org.jboss.weld.proxies.EntityManager$1722484474$Proxy$_$$_WeldClientProxy.getTransaction(Unknown Source)
    br.com.hebi.interceptor.EntityManagerInterceptor.before(EntityManagerInterceptor.java:23)
    br.com.hebi.interceptor.EntityManagerInterceptor$Proxy$_$$_WeldClientProxy.before(Unknown Source)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    net.vidageek.mirror.provider.java.PureJavaMethodReflectionProvider.invoke(PureJavaMethodReflectionProvider.java:38)
    net.vidageek.mirror.invoke.MethodHandlerByMethod.withArgs(MethodHandlerByMethod.java:54)
    br.com.caelum.vraptor.interceptor.StepInvoker.invokeMethod(StepInvoker.java:49)
    br.com.caelum.vraptor.interceptor.StepInvoker.tryToInvoke(StepInvoker.java:40)
    br.com.caelum.vraptor.interceptor.StepInvoker$Proxy$_$$_WeldClientProxy.tryToInvoke(Unknown Source)
    br.com.caelum.vraptor.interceptor.InterceptorExecutor.execute(InterceptorExecutor.java:63)
    br.com.caelum.vraptor.interceptor.InterceptorExecutor$Proxy$_$$_WeldClientProxy.execute(Unknown Source)
    br.com.caelum.vraptor.interceptor.AspectStyleInterceptorHandler.execute(AspectStyleInterceptorHandler.java:84)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    br.com.caelum.brutauth.interceptors.BrutauthMapInterceptor.intercept(BrutauthMapInterceptor.java:36)
    br.com.caelum.brutauth.interceptors.BrutauthMapInterceptor$Proxy$_$$_WeldClientProxy.intercept(Unknown Source)
    br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:58)
    br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:83)
    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.execute(ToInstantiateInterceptorHandler.java:58)
    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(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    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:118)

E sobre o version apenas adicionei o atributo no meu model

@Version
private Integer versao;

E criei o campo como integer no banco e adicionei no formulario:

<input name="versao" type="hidden" value="${obj.versao}">

Abraços

Oi Matheus, tudo bem?

Veja se você setou a propriedade hibernate.cache.region.factory_class no seu persistence.xml.

Quanto ao @Version verifique se o valor da versão chega no input. O seu problema geralmente acontece quando inserimos uma entidade sem mandar a versão.

Abraços!

Fala ai Leonardo, quanto ao hibernate eu setei sim:

<property name="hibernate.cache.use_second_level_cache" value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory"/>

E quanto ao @Version o valor esta chegando na input sim.

Oi Matheus,

Sobre @Version: Tente isolar o probema. Crie um teste para ver o @Version funcionando sem o Vraptor. Assim a gente pode verificar se o problema realmente está relacionado com Hibernate ou não.

Sobre o cache, repare que na exceção aparece uma outra chave:

`hibernate.cache.region.factory_class``

Abs

Ok, vou testar o @Version separado.

Sobre o cache não entendi.

Esta faltando anotação no persistence.xml ?

solução!

Fala Matheus, vamos lá!

A propriedade hibernate.cache.use_second_level_cache indica se queremos ativar o cache de segundo nível ou não. Nesse caso, ela vai receber o valor true ou false, ok?

O valor que você colocou ("org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory"), na verdade, é o nome da classe do provider do cache. Esse valor tem que ser setado na propriedade hibernate.cache.region.factory_class.

Ou seja:

<property name="hibernate.cache.use_second_level_cache" value="true"/>

Tudo bem?

Abraços!

Leonardo, show de bola, o cache esta funcionando.

Desculpe pela desatenção, lendo o PDF com mais calma agora pude ver que no código java estava com a property correta, porém o código em persistence esta errado, depois da uma arrumada la.

Abraços, valeu.