Accessing Coherence Cache hosted on Weblogic 12c from Java Client - caching

I would like to access and manipulate Coherence Cache configured on a cluster defined with in WebLogic 12c as a GAR via API in an java application.
Though I can get a reference to cache via NamedCache API but am unable to get objects added to it via web logic JSP page.
Any tips will be appreciated

As long as you have the same cluster and cache configuration, all you have to do from your stand-alone Java process is to call into the CacheFactory class and ask for the cache.

Related

Infinispan - Can I create DefaultCacheManager for each web application in the server

I do not understand the following statement of DefaultCacheManager's Java doc. It says
CacheManagers are heavyweight objects, and we foresee no more than one CacheManager being used per JVM
Am I allowed to create DefaultCacheManager programmatically for each web application in the server? For example, I have two web applications, A and B. They are running in the JBoss AS (standalone only). Each web application (A and B) creates own DefaultCacheManager object.
Yes, you can create more cache managers. The term heavyweight here means that cache manager contains thread pools, JGroups channels (that means consumed ports) etc. so you should not create too many of these.
The situation might be a bit different in an application server with deep integration - some of the resources can be shared there. Check out the Infinispan subsystem - cache manager then maps to a cache-container. It's perfectly fine to have multiple cache containers in the configuration.
In application server, the applications should not create the cache managers; these should be only injected (e.g. through CDI) to your webapp.

Adding HttpSession Object to Infinispan cache

We have started using infinispan cache with wildfly 13 in our web application. The web application is deployed in wildfly domain mode in a cluster of two node with one acting as master and the other as slave. In the application we have an admin feature, where the admin can terminate a user.
So what we want to do is add session objects to Infinispan cache and retrieve it and terminate it when required. I am aware that HttpSession object is not serializable hence it cannot be added to cache but every attribute added to the session object is serilizable so my question is, is there a workaround for the issue? Because right now we get a NotSerializable error when I try to add session to cache and it's also no longer possible to retrieve session from sessionId and terminate it due to security reasons.
There is no need to manually interact with the Infinispan cache: WildFly transparently supports full http session clustering with Infinispan. See https://docs.jboss.org/author/display/WFLY10/High+Availability+Guide

How to enable cache server JNDI lookup support in Coherence 12.2.1?

I am trying to access Coherence 12.2.1's cache (deployed in data tier) from application tier (deployed in application tier) that staying same Coherence cluster with different WebLogic clusters.
Oracle stated:
A component-scoped JNDI tree can be used in EJBs, servlets, or JSPs to reference the NamedCache.
To use a component-scoped JNDI lookup, define a resource-ref of type com.tangosol.net.NamedCache in either the web.xml or ejb-jar.xml file. Example 3-2 illustrates a <resource-ref> stanza that identifies myCache as the NamedCache.
in https://docs.oracle.com/cd/E24329_01/web.1211/e24442/coh_wls.htm#COHWL117
I developed a Coherence application and deploy it into local storage enabled WebLogic server (coherence managed server). I used Application Lifecycle Listener to access and initialise cache, it works fine.
I can find the cache was populate up in Coherence cache server by using VisualVM, please see attachment.
But unfortunately, I can't find any thing about the cache in my WebLogic managed server JNDI tree, Please find attachment.
I tried to find out a way to enable Coherence cache server (it was integrated into WebLogic 12c) support JNDI look up.
I found something like this:
<cache-config xmlns:jndi="class://com.oracle.coherence.environment.extensible.namespaces.JNDINamespaceContentHandler">
...
</cache-config>
But unfortunately again, com.oracle.coherence.environment.extensible.namespaces.JNDINamespaceContentHandler was removed from WebLogic 12c. Which means there is no way to enable Coherence data cache JNDI name configuration in Coherence 12cR2.
Any advice please!!
Were you able to create the ConnectionFactory, Outbound pools, etc ?
I suggest you take a look at this post here. It should help you out.
Hope it helps !!

enable hibernate app to use clustered hazelcast

our prod environment architecture is decided to be like this:
2 machines that each of them have 2 tomcat instances (on vm). there is spring web app with hibernate running on tomcat.
there are also 2 db instances distributed to both machines.
so, we think that hazelcast fits this achitecture well. hazelcast will be second level cache for hibernate, it will manage clustered cache over db instances.
we installed hibernate server and defined our clusters on it.
i've searched offical hazelcast doc and several sites but i couldnt find the way to configure hibernate to use this hazelcast server as L2 cache.
we dont want to change our existing app. we'll keep using hibernate as it is. is it possible? if so, how we can configure hazelcast server on our web app?
I think it is important to understand that your probably don't want to have a standalone Hazelcast cluster/server; what you normally do is to embed Hazelcast within your application.
Like Miko said, you can just enable Hazelcast to be used as second level cache; no need to make any fundamental changes.
I also don't understand what you mean with 'hibernate server', because Hibernate is just an OR mapper library and has no concept of server.
So can you tell a bit more what you want so we can help you out?

Restoring JSF application state using memcached as session fail-over

I set up two equal tomcat servers that host the same web application (Sun RI JSF 2 / Tomahawk). For load balancing and fail-over scenarios I use an nginx server as reverse proxy delegating the request to the one or the other server. Right now one tomcat is defines as backup solution, so that tomcat server 1 handles all the requests. When I kill the process of tomcat 1, nginx nicely delegates the following requests to tomcat server 2. In order to reuse the session data I configured both tomcat servers to use memcached as session store. JSF is configured to store its state on the server.
Concerning the log files, this setup looks quite nice and session data is read and stored using the memcached server. This for example facilitates using the web application without the need to login again even if tomcat 1 has been shut down.
Nevertheless it seems as if my (session scoped) backing beans are not stored or being used after restoring the session respectively. Form fields are left empty that are supposed to be filled with the data from the session bean.
Is it possible to do such things with the mentioned technologies at all?
With memcached-session-manager and OWB you should use tomcat < 7.0.22 as in this version the notification of ServletRequestListeners got changed (which is the mechanism used by OWB for failover support).
I'm currently working on a new version of msm that works with OWB and tomcat >= 7.0.22.

Resources