haproxy - how to share a session between two different tomcats - session

Is it possible to share a session among 2 tomcats that runs the same web application and which is both balanced by haproxy? (haproxy is round robin based, and not using sticky-session)
by sharing i mean creating the session in one place (haproxy or tomcat) and be able to get it from the other tomcat.
(our goal is statless web application servers)..
Thanks!

It is possible. You can cluster your tomcat servers together.
Configure Tomcat to Share Sessions
The key to enable session sharing is to declare two XML elements: one
in your application's web.xml (1) and the other in Tomcat's server.xml
(2):
<distributable />
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" />
Important Note: Your session attributes must be serializable.
Sources:
Krams - Clustering and Load Balancing... - very detailed step-by-step guide.
Apache - Clustering HOW-TO - manual.

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.

is there a equivalent tomcat valves concept in websphere liberty profile?

I have a webapplication which was deployed on tomcat and uses tomcat values, now the application is moving to websphere liberty and am not sure similar concept exists in liberty.
Is there an equivalent tomcat valves concept in websphere libery profile? If yes, how can we achieve ?
You can white/blacklist hostnames and ip addresses on a per-endpoint basis in server.xml. Blocked ones will get a connection reset message.
<httpEndpoint httpPort="19080" httpsPort="19443"
id="defaultHttpEndpoint" tcpOptionsRef="myTcpOptions" host="*"/>
<tcpOptions id="myTcpOptions" hostNameExcludeList="*.foo.com,*.ibm.com" />
There's more info on that here:
https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/urun_chain_typetcp.html
If you need different exclusions per app, you can use configure multiple endpoints and map them to applications using virtual hosts.
https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/cwlp_virtual_hosts.html

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 !!

IBM Worklight - Can Worklight be deployed to an existing WAS server?

Can a Worklight Server be deployed to a WebSphere application server which also runs other non-Worklight .ear applications? Or does Worklight need its own separate instance of WAS?
Just like you can deploy multiple instances of Worklight (v6 and above) projects - multiple .war files to the same WAS application server, there should not be issues to deploy it to an application server running other services.
That said, possible issues to consider:
When deploying a Worklight project, you will want to enable "application security"
(in the WAS admin console, Security > Global Security). If there are some other web
applications for which application security is undesired, you need a different WAS server
instance.
Setting up, enabling and migrating security
The list of users that can use the web applications are configured through LDAP or
"federated repositories", or similar. If, for Worklight, you need to use a completely
different set of user logins than for the other web applications, then you need to use
multiple "security domains".
Configuring multiple security domains
The machine hosting the application server will probably need memory upgrades...
Deploying the Enterprise Archive (EAR) Using the WebSphere Admin Console
Probably also need to make clear seperation where required:
IBM WebSphere Developer Technical Journal: Co-hosting multiple versions of J2EE applications
Worklight is itself an application running inside a web container, whether that be Tomcat, WAS Liberty, or full WAS. It's essentially a layer running underneath the container to handle requests for Worklight applications, fielding their context root requests. If you create the WAR file for your Worklight app and extract out the deployment descriptor you'll find all the necessary filters and listeners that most other apps would have.
Things like adapters and wlapps are "installed" to this underlying layer, and are merely extracted and stored as whatever was packaged with them, such as the JS and CSS you used to make you app. In fact, with a standard Liberty install you can typically find your adapters in plain sight at (for the WL5.0.6 instance I have handy, it's different for WL6):
/opt/IBM/Worklight/server/wlp/usr/servers/worklightServer/worklight.home/worklight/data/export/adapters
So, in addition to what Idan has said, I also present you with the following docs (assuming WL6)
Overview of the Worklight Server installation process
Given my own experience, you should be perfectly able to install other EAR and WAR files to your existing WAS instance, just make sure your context roots are unique, as always ;)
I also second the memory considerations.

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?

Resources