Infinispan L2C Not working (Wildfly version 27.0.0)

94 views
Skip to first unread message

Tushal Joggesser

unread,
Apr 22, 2024, 11:44:35 AMApr 22
to WildFly
Hi Team, 

I have configured L2C for Wildfly 27.0.0 and it seems that nothing is being cached to the cache region.
Please see the logs and configurations below and advise.

Log: 
INFO  [org.hibernate.engine.internal.StatisticalLoggingSessionEventListener] (ForkJoinPool.commonPool-worker-2) Session Metrics {
2024-04-22T09:33:33.641343532Z     10470431 nanoseconds spent acquiring 1 JDBC connections;
2024-04-22T09:33:33.641347390Z     243743 nanoseconds spent releasing 1 JDBC connections;
2024-04-22T09:33:33.641350784Z     10639930 nanoseconds spent preparing 1 JDBC statements;
2024-04-22T09:33:33.641354257Z     16397136 nanoseconds spent executing 1 JDBC statements;
2024-04-22T09:33:33.641357856Z     0 nanoseconds spent executing 0 JDBC batches;
2024-04-22T09:33:33.641363023Z     0 nanoseconds spent performing 0 L2C puts;
2024-04-22T09:33:33.641366779Z     0 nanoseconds spent performing 0 L2C hits;
2024-04-22T09:33:33.641370212Z     0 nanoseconds spent performing 0 L2C misses;
2024-04-22T09:33:33.641373472Z     29270715 nanoseconds spent executing 1 flushes (flushing a total of 1 entities and 0 collections);
2024-04-22T09:33:33.641377005Z     0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)


Standalone-full:
<local-cache name="response-codes" statistics-enabled="false">
<locking isolation="REPEATABLE_READ"/>
<transaction locking="OPTIMISTIC" mode="FULL_XA"/>
<heap-memory size="500"/>
<expiration lifespan="36000000" max-idle="3600000"/>
</local-cache>

Class: 
@Entity
@Table(name = "response_codes", schema = "dbo")
@XmlRootElement
@Getter
@Setter
@ToString
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "response-codes")
@NamedQueries({
@NamedQuery(name = "ResponseCodes.findAll", query = "SELECT r FROM ResponseCodes r")})
public class ResponseCodes 
Persistence.xml
<property name="jakarta.persistence.sharedCache.mode" value="ENABLE_SELECTIVE"/>
<property name="jakarta.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.useUnicode" value="yes"/>
<property name="hibernate.connection.characterEncoding" value="UTF-8"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<!-- Use Infinispan second level cache provider -->
<property name="hibernate.cache.region.factory_class" value="infinispan"/>
<property name="hibernate.generate_statistics" value="true"/>
<property name="hibernate.cache.infinispan.statistics" value="true" />
<!--<property name="hibernate.transaction.jta.platform" value="org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform" />-->
<!--<property name="hibernate.cache.region.factory_class" value="org.infinispan.hibernate.cache.v53.InfinispanRegionFactory"/>-->
<!--<property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/container/hibernate"/>-->
<!--https://infinispan.org/docs/13.0.x/titles/hibernate/hibernate.html#configuration_properties-->
<!--payment gateway ear-->
<property
name="hibernate.cache.infinispan._paymentgateway-ear.ear#softconnect_PU_.com.softconnectltd.paymentgateway.entity.ResponseCodes.cfg"
value="response-codes"/>

Paul Ferraro

unread,
Apr 23, 2024, 8:32:46 AMApr 23
to WildFly
Please remove your "hibernate.cache.region.factory_class" property, which otherwise bypasses WildFly's default region factory implementation.

Tushal Joggesser

unread,
Apr 23, 2024, 12:45:01 PMApr 23
to Paul Ferraro, WildFly
Hi Paul, 

I have tried to remove the details as requested, but still face same issue. 
Can you confirm the naming convention in the persistence "softconnect_PU" ? 

Should it be : 

name="hibernate.cache.infinispan._paymentgateway-ear.ear#softconnect_PU_.com.softconnectltd.paymentgateway.entity.ResponseCodes.cfg

Or 
name="hibernate.cache.infinispan.paymentgateway-ear.ear#softconnect_PU.com.softconnectltd.paymentgateway.entity.ResponseCodes.cfg

I have tried both the above but same result. 

Sent from Outlook for Android

From: wil...@googlegroups.com <wil...@googlegroups.com> on behalf of Paul Ferraro <paul.f...@redhat.com>
Sent: Tuesday, April 23, 2024 4:32:45 PM
To: WildFly <wil...@googlegroups.com>
Subject: Re: Infinispan L2C Not working (Wildfly version 27.0.0)
 
--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/8f719d86-389c-4353-bffc-8061b20a0597n%40googlegroups.com.

Tushal Joggesser

unread,
Apr 25, 2024, 3:03:49 AMApr 25
to WildFly
Hi @Paul,

Please any update ? 

Regards, 
Tushal

tus...@softconnectltd.com

unread,
Apr 29, 2024, 4:14:21 AMApr 29
to WildFly

Hi,

Any update for the issue mentioned?

 

 

 

 

Regards,

Tushal

 

cid:image001.png@01D89094.DD801D30

 

Disclaimer and confidentiality note:

Everything in this email and any attachments relating to the official business of Paywise Limited is proprietary to Paywise Limited.

It is confidential, legally privileged, and protected by law. We do not own and endorse any other content.

The person addressed in the email is the solely authorized recipient.

Please notify the sender immediately if it has unintentionally reached you and does not read disclose or use the content in any way.

Paywise Limited cannot assume that the integrity of this communication has been maintained nor that it is free of errors, viruses, interception, or interference.

image001.png

Tushal Joggesser

unread,
May 1, 2024, 11:27:18 AMMay 1
to WildFly
@Paul, can you please advise what's wrong ?

Paul Ferraro

unread,
May 3, 2024, 7:05:56 AMMay 3
to WildFly
<property name="hibernate.cache.infinispan.paymentgateway-ear.ear#softconnect_PU.com.softconnectltd.paymentgateway.entity.ResponseCodes.cfg" value="response-codes"/>
would normally direct the 2LC implementation to create the cache used to store ResponseCodes entities via the "response-codes" cache configuration - however, your @Cache annotation overrides the caching region.
Remove the region override from your @Cache annotation.

Tushal Joggesser

unread,
Jun 10, 2024, 6:20:23 AMJun 10
to WildFly
Hi Paul, 

Removed  @Cache , but still same issues.

Paul Ferraro

unread,
Jun 10, 2024, 8:32:41 AMJun 10
to WildFly
Are you certain the actions taken by your application would actually hit the 2nd level cache?  For example, you don't have query caching enabled, so I would not expect a cache hit/miss unless a specific response code entity was requested.
Otherwise, can you paste the configuration used during your most recent attempt?

tus...@softconnectltd.com

unread,
Jun 10, 2024, 8:41:51 AMJun 10
to Paul Ferraro, WildFly

Hi Paul,

Thanks for your reply.
There’s no query caching, I’m expecting the application to read from the response-codes cache whenever a record was already called by the application and not calling the DB.

Below are the updated sample configs.

 

Persistence.xml

<property name="jakarta.persistence.sharedCache.mode" value="ENABLE_SELECTIVE"/>
<property
name="jakarta.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property
name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property
name="hibernate.connection.useUnicode" value="yes"/>
<property
name="hibernate.connection.characterEncoding" value="UTF-8"/>
<property
name="hibernate.cache.use_second_level_cache" value="true"
/>
<property
name="hibernate.generate_statistics" value="false"/>

<property
        
name="hibernate.cache.infinispan.paymentgateway-ear.ear#softconnect_PU.com.softconnectltd.paymentgateway.entity.ResponseCodes.cfg"
       
value="response-codes"/>

 

Class:

 

Standalone-full


<local-cache name="response-codes" statistics-enabled="true">
    <locking
isolation="REPEATABLE_READ"/>
   
<!--                    <transaction locking="OPTIMISTIC" mode="FULL_XA"/>-->
    <!--                    <file-store shared="true" preload="true"/>-->
   
<heap-memory size="500"/>
    <expiration
lifespan="36000000" max-idle="3600000"/>

</local-cache>

 

Let me know if there’s any working sample I can refer to .

 

Regards,

Tushal

image001.png

Tushal Joggesser

unread,
Jun 18, 2024, 5:50:36 AMJun 18
to WildFly
Any update please?

Paul Ferraro

unread,
Jun 27, 2024, 10:07:19 AM (10 days ago) Jun 27
to WildFly
This property does not look correct:
<property name="hibernate.cache.infinispan.paymentgateway-ear.ear#softconnect_PU.com.softconnectltd.paymentgateway.entity.ResponseCodes.cfg" value="response-codes"/>

Since your deployment uses EAR packaging, the deployment name part, i.e. the bit between "hibernate.cache.infinispan." and "#", should contain "ear-name/war-name" or "ear-name/jar-name".
e.g.
<property name="hibernate.cache.infinispan.my-app.ear/my-app.war#persistent-unit-name.com.softconnectltd.paymentgateway.entity.ResponseCodes.cfg" value="response-codes"/>
Reply all
Reply to author
Forward
0 new messages