0
votes

I can see caching exception sometimes only, I am not able to reproduce as well. So just wanted to know how shall I proceed.

We are using Jboss As 5.1 and Hibernate 3.3.2.GA version

We have an entity

 @Table(name = "TBL_COUNTRY")
 @Entity
 @Cache(region="/country", usage=CacheConcurrencyStrategy.READ_ONLY)
 public class Country implements Serializable {
}

Hibernate config:

<properties>
    <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
    <property name="hibernate.show_sql" value="false" />
    <property name="hibernate.format_sql" value="false" />

    <!-- Clustered cache with TreeCache -->
    <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
    <property name="hibernate.cache.use_second_level_cache" value="true" />
    name="hibernate.cache.use_query_cache" value="true" />
    name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory" />

    <property name="hibernate.cache.region.jbc2.query.localonly" value="true"/>
    <property name="hibernate.cache.region.jbc2.cachefactory" value="java:CacheManager" />
    <property name="hibernate.cache.region.jbc2.cfg.entity" value="mvcc-entity" />
    <property name="hibernate.cache.region.jbc2.cfg.query"  value="local-query" />
    <property name="hibernate.cache.region_prefix" value="ecommerce"/>

    <property name="jboss.depends.1" value="jboss:service=Naming"/>
    <property name="jboss.depends.2" value="jboss:service=TransactionManager"/>
    <property name="jboss.depends.3" value="jboss.cache:service=CacheManager"/>
    <property name="jboss.depends.4" value="jboss.jca:name=ecomm-ds,service=ManagedConnectionPool"/>
</properties>

Log is attached

2017-07-26 18:31:45,849 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (http-XXXXXXXXXX%2F10.137.96.103-8080-17) [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@1e9b02ed org.jboss.cache.optimistic.DataVersioningException: Transaction attempted to create /ecommerce/currency/QUERY/sql: select currency2_.ID as ID7_, currency2_.CONVERSION_FACTOR as CONVERSION2_7_, currency2_.ISO_NAME as ISO3_7_, currency2_.NAME as NAME7_, currency2_.SYMBOL as SYMBOL7_ from TBL_COUNTRY country0_ left outer join TBL_SHIPPING_ZONE_COUNTRY country0_1_ on country0_.ID=country0_1_.COUNTRY_ID inner join TBL_SHIPPING_ZONES shippingzo1_ on country0_1_.SHIPPING_ZONE_ID=shippingzo1_.ID inner join TBL_CURRENCIES currency2_ on shippingzo1_.CURRENCY_ID=currency2_.ID where country0_.ID=?; parameters: ; named parameters: {countryCode=US} anew. It has already been created since this transaction started, by another (possibly remote) transaction. We have a concurrent creation event. at org.jboss.cache.interceptors.OptimisticValidatorInterceptor.visitOptimisticPrepareCommand(OptimisticValidatorInterceptor.java:116) at org.jboss.cache.commands.tx.OptimisticPrepareCommand.acceptVisitor(OptimisticPrepareCommand.java:55) at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116) at org.jboss.cache.interceptors.OptimisticLockingInterceptor.visitOptimisticPrepareCommand(OptimisticLockingInterceptor.java:89) at org.jboss.cache.commands.tx.OptimisticPrepareCommand.acceptVisitor(OptimisticPrepareCommand.java:55) at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116) at org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131) at org.jboss.cache.commands.AbstractVisitor.visitOptimisticPrepareCommand(AbstractVisitor.java:155) at org.jboss.cache.commands.tx.OptimisticPrepareCommand.acceptVisitor(OptimisticPrepareCommand.java:55) at org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116) at org.jboss.cache.interceptors.TxInterceptor.runPreparePhase(TxInterceptor.java:682) at org.jboss.cache.interceptors.TxInterceptor$LocalSynchronizationHandler.beforeCompletion(TxInterceptor.java:1102) at org.jboss.cache.interceptors.OrderedSynchronizationHandler.beforeCompletion(OrderedSynchronizationHandler.java:81) at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101) at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269) at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89) at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177) at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1423) at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:137) at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75) at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:170) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.security.RunAsSecurityInterceptorv2.invoke(RunAsSecurityInterceptorv2.java:94) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorv2.invoke(RoleBasedAuthorizationInterceptorv2.java:201) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41) at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.interceptor.EJB3TCCLInterceptor.invoke(EJB3TCCLInterceptor.java:86) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:323) at org.jboss.ejb3.stateless.StatelessContainer.invokeEndpoint(StatelessContainer.java:691) at org.jboss.wsf.container.jboss50.invocation.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:96) at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:222) at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:474) //omitted

1
Share please simple project with this problem part via git (to check configuration\mapping\TM...). This issue can have different reasons.Sergii
Do you write region any time? Its just ready only?Vish
Yes We need to write very few times. mostly it is read onlyArvind
You can not update it, since it read only. You have to change the strategy.Vish

1 Answers

0
votes

If your application needs to read, but not modify, instances of a persistent class, a read-only cache can be used. This is the simplest and optimal performing strategy. It is even safe for use in a cluster. More details.