« Back

How do I cluster Liferay with Terracotta?

Company Blogs August 31, 2010 By Mika Koivisto Staff

That's a question I've head many times and in this post I will show you  just how to do that. These instructions are for Liferay 6 CE GA3 Tomcat 6.0 bundle however you can use any app server supported by Terracotta but the location and some configuration might be slightly different. So to get started you need to download:

Next step is to install Liferay and Terracotta. For the purposes of this post I won't go into great detail with the installation as both Terracotta and Liferay has good documentation. Basically the installation consist of unpacking the packages to a directory. From now on I will refer to those locations as LIFERAY_HOME and TERRACOTTA_HOME and inside LIFERAY_HOME we will have tomcat directory which I will refer as TOMCAT_HOME. Normally you would also install Liferay and Terracotta in separate servers but I will post a separate post addressing the recommended architecture. For now we can install everything on the same machine and run Terracotta with default configuration for development purposes.

Normally when clustering Liferay you need to address following components: EhCache and Hibernate, Quartz Scheduler, Document Library, Search Engine and optionally Session Replication. For Document Library and Search Engine Terracotta doesn't offer anything new so you make those centrally available the same way as before. For example SAN for DL and SOLR for Search and Indexing. So we are left with EhCache and Hibernate, Quartz and Session Replication that we can address with Terracotta. 

EhCache and Hibernate Second Level Cache

  1.  Remove ehcache.jar that is bundled with Liferay (located in TOMCAT_HOME/webapps/ROOT/WEB-INF/lib)
  2. Copy all jars in TERRACOTTA_HOME/ehcache/lib to TOMCAT_HOME/webapps/ROOT/WEB-INF/lib
  3. Copy TERRACOTTA_HOME/common/terracotta-toolkit-1.0-runtime-<version>.jar to TOMCAT_HOME/webapps/ROOT/WEB-INF/lib
  4. Create my-ehcache folder to TOMCAT_HOME/webapps/ROOT/WEB-INF/classes
  5. Create a hibernate-terracotta.xml and a liferay-multi-vm-terracotta.xml.
  6. Adjust terracottaConfig in hibernate-terracotta.xml and liferay-multi-vm-terracotta.xml to point to your Terracotta servers. Like this: <terracottaConfig url="localhost:9510"/>
  7. Add following properties to your portal-ext.properties file:
    ehcache.multi.vm.config.location=/my-ehcache/liferay-multi-vm-terracotta.xml
    
net.sf.ehcache.configurationResourceName=/my-ehcache/hibernate-terracotta.xml
    
hibernate.cache.region.factory_class=net.sf.ehcache.hibernate.EhCacheRegionFactory

Quartz

  1. Remove quartz.jar that is bundled with Liferay (located in TOMCAT_HOME/webapps/ROOT/WEB-INF/lib)
  2. Copy TERRACOTTA_HOME/quartz/quartz-terracotta-<version>.jar and quartz-all-<version>.jar to TOMCAT_HOME/webapps/ROOT/WEB-INF/lib
  3. Add following properties to your portal-ext.properties:
    org.quartz.jobStore.class = org.terracotta.quartz.TerracottaJobStore
    
org.quartz.jobStore.tcConfigUrl = localhost:9510
  4. Extract portal.properties from portal-impl.jar and place it in TOMCAT_HOME/webapps/ROOT/WEB-INF/classes
  5. Comment out following properties in portal.properties
    #org.quartz.jobStore.dataSource=ds

    #org.quartz.jobStore.isClustered=false
    
#org.quartz.jobStore.misfireThreshold=60000
    
#org.quartz.jobStore.tablePrefix=QUARTZ_
    
#org.quartz.jobStore.useProperties=false

Session Replication

This is highly container specific so refer to Terracotta documentation for specific instructions. Following steps are for Tomcat 6.0.

  1. Copy TERRACOTTA_HOME/sessions/terracotta-session-<version>.jar to TOMCAT_HOME/lib
  2. Copy TERRACOTTA_HOME/common/terracotta-toolkit-1.0-runtime-<version>.jar to TOMCAT_HOME/lib
  3. Edit TOMCAT_HOME/conf/Catalina/localhost/ROOT.xml and add following line right after <Context>
    
<Valve className="org.terracotta.session.TerracottaTomcat60xSessionValve" tcConfigUrl="localhost:9510"/>

Testing The Configuration

Testing your configuration is simple:

  1. Startup your Terracotta Server
    TERRACOTTA_HOME/bin/start-tc-server.sh
  2. Startup your Tomcat
    TOMCAT_HOME/bin/startup.sh
  3. Before Tomcat has fully started you should see following lines in your Tomcat console log:
    2010-09-01 21:35:40,059 INFO - Terracotta 3.3.0, as of 20100716-140706 (Revision 15922 by cruise@rh5mo0 from 3.3)
    2010-09-01 21:35:40,566 INFO - Successfully loaded base configuration from server at 'localhost:9510'.
  4. Now browse http://localhost:8080 to verify that your portal is running. 
  5. Now launch Terracotta Developer Console to verify that EhCache, Hibernate, Quartz and Sessions are seen by Terracotta. You can launch dev console with following command:
    TERRACOTTA_HOME/bin/dev-console.sh
  6. Once you are connected to your Terracotta you should see Ehcache, Hibernate, Quartz and Sessions under My application which indicates that all of them are connected and recognized by Terracotta. Now you can use Dev Console to see what's inside your cache or session. 

Closing Remarks

Now as you can see it is quite easy the cluster Liferay with Terracotta express installation. Now if you want to use the DSO approach it is whole another beast as it involves tedious instrumentation. If you are a Liferay EE customer and want to get supported version of both Liferay and Terracotta contact your Liferay sales rep and ask about Liferay Terracotta Edition. 

Threaded Replies Author Date
Nice post! Thank you, Mika. Jonas Yuan September 1, 2010 4:04 PM
excellent post! James Min September 1, 2010 8:12 PM
Mika, this is good stuff! Thanks. Sampsa Sohlman September 2, 2010 8:03 AM
Hi Mika, Nice Post. Looks like the two file... Shagul Khajamohideen September 2, 2010 12:47 PM
Should be accessible now. Thanks for letting me... Mika Koivisto September 2, 2010 1:30 PM
Great post but ... I ran into a problem that... James Denmark September 2, 2010 4:04 PM
Looks like you configured... Mika Koivisto September 2, 2010 4:10 PM
Hello again Mika. I'm sorry to ask this... James Denmark September 9, 2010 8:21 PM
Hello do you successfully run clustered liferay... Eric Grandjean September 10, 2010 2:16 AM
So the first time around I had a working... James Denmark September 10, 2010 7:23 AM
Have you done this setup with everything on one... Mika Koivisto September 10, 2010 2:23 AM
These were separate servers - two... James Denmark September 10, 2010 7:24 AM
James, did you manage to resolve the... Stuart Hirst September 14, 2010 12:52 AM
No. I still haven't resolved it and have moved... James Denmark September 14, 2010 6:18 AM
Hey Guys, sorry it took so long but I've now... Mika Koivisto September 16, 2010 7:42 AM
Thanks for looking into this Mika. To make... James Denmark September 16, 2010 8:15 AM
That is correct. Mika Koivisto September 16, 2010 8:17 AM
Hi Mike, I am also facing the problem, can... satish M December 12, 2010 11:06 PM
The serializable problem might have been fixed... Urban Lindberg January 26, 2011 5:34 AM
I am also experiencing the same problem. I... Stuart Hirst September 10, 2010 2:30 AM
very cool! something for me to try when I have... Wilson Man September 2, 2010 5:36 PM
You write "Extract portal.properties from... Sampsa Sohlman September 3, 2010 7:51 AM
Yeah, that is correct. You must disable those... Mika Koivisto September 3, 2010 8:20 AM
Thanks for the excellent post. I have come... Stuart Hirst September 9, 2010 7:17 AM
Hmm. I've usually seen this if Terracotta... Mika Koivisto September 9, 2010 7:31 AM
Mika, Thanks for your advice. I have managed... Stuart Hirst September 10, 2010 2:17 AM
Its good, Thank you, Mika. N K Rao October 20, 2010 1:48 AM
Hi Mika, i am also facing the above... N K Rao October 20, 2010 1:57 AM
I can't get this to work. Using a plain... Keith Scott February 8, 2011 5:00 AM
Hi Mika, I am getting following error while... Ankit Srivastava April 12, 2012 11:17 PM
To solve the above problem, in... Danil Mironov August 21, 2013 2:42 AM
Storing the session in terracotta works fine... Tom Mahy May 30, 2012 1:24 AM
Are there any plans to update/post instructions... Keith O'Connell June 28, 2012 7:48 AM
[...] I have 2 server. - Server1: OS is Ubuntu... Anonymous July 3, 2012 10:08 PM
Not work with Liferay 6.1 :( Nguyen Trong Tri July 4, 2012 5:30 AM
[...] In our project based o Liferay running on... Anonymous November 20, 2013 8:42 AM
Hi All I am facing the issue when integrating... Hari babu May 24, 2014 5:35 AM
Hi there, I currently try to integrate... Sébastien LEVER May 27, 2015 8:33 AM
Hello Sébastien: have you been able to solve... Van Tuan DANG April 5, 2016 8:14 AM
The correct answer is it depends. For example... Mika Koivisto April 5, 2016 8:21 AM
Thank you Mika for this quick answer. The issue... Van Tuan DANG April 5, 2016 9:00 AM
Don't use cache replication for Liferay caches.... Mika Koivisto April 5, 2016 9:12 AM
Hi Van Tuan, I finaly use ClusterLInk in my CE... Sébastien LEVER April 5, 2016 1:03 PM
Thank you for your replies Mika, Sébastien. I... Van Tuan DANG April 5, 2016 11:38 PM

Nice post! Thank you, Mika.
Posted on 9/1/10 4:04 PM.
excellent post!
Posted on 9/1/10 8:12 PM.
Mika, this is good stuff! Thanks.
Posted on 9/2/10 8:03 AM.
Hi Mika,
Nice Post. Looks like the two file links are not accessible. Can you please verify that?
Posted on 9/2/10 12:47 PM.
Should be accessible now. Thanks for letting me know.
Posted on 9/2/10 1:30 PM in reply to Shagul Khajamohideen.
Great post but ... I ran into a problem that hopefully you help with.

Followed instructions as above except I have the terracotta server running on a different box. Made the ip address changes as appropriate and created the tc-config.xml file on the terracotta server.

Now when I fire up Liferay, everything looks good through the terracotta startup and then I start getting exceptions:

2010-09-02 18:52:11,606 INFO - Terracotta 3.3.0, as of 20100716-140706 (Revision 15922 by cruise@rh5mo0 from 3.3)
2010-09-02 18:52:12,034 INFO - Successfully loaded base configuration from server at '10.109.206.10:9510'.
2010-09-02 18:52:12,080 INFO - Successfully loaded base configuration from file at '/usr/local/liferay/liferay-portal-6.0.5/tomcat-6.0.26/temp/tc-config40885335344­94940638.xml'.
2010-09-02 18:52:12,208 INFO - Log file: '/root/terracotta/client-logs/terracotta-client.log'.
2010-09-02 18:52:13,956 INFO - Connection successfully established to server at 10.109.206.10:9510
18:52:40,171 INFO [PortalImpl:277] Global lib directory /usr/local/liferay/liferay-portal-6.0.5/tomcat-6.0.26/lib/ext/
18:52:40,175 INFO [PortalImpl:297] Portal lib directory /usr/local/liferay/liferay-portal-6.0.5/tomcat-6.0.26/webapps/ROOT/WEB-INF/lib/
S­tarting Liferay Portal Community Edition 6.0.5 CE (Bunyan / Build 6005 / August 16, 2010)
18:52:55,917 ERROR [velocity:151] ResourceManager.getResource() load exception
18:52:55,919 ERROR [velocity:151] net.sf.ehcache.CacheException: java.io.NotSerializableException: org.apache.velocity.Template
at org.terracotta.modules.ehcache.store.ValueModeHandlerSerialization.createTimesta­mpedValue(ValueModeHandlerSerialization.java:56)

etc..... any suggestions?
Posted on 9/2/10 4:04 PM.
Looks like you configured ehcache.single.vm.config.location=/ehcache/liferay-single-vm.xml to use Terracotta. This is definite no no! Single VM cache is not distributable as the objects are not Serializable.
Posted on 9/2/10 4:10 PM in reply to James Denmark.
very cool! something for me to try when I have some time! =)
Posted on 9/2/10 5:36 PM.
You write "Extract portal.properties from portal-impl.jar and place it in TOMCAT_HOME/webapps/ROOT/WEB-INF/classes Comment out following properties in portal.properties"

So just to confirm. there is something that normal portal-ext.properties override does not work?
Posted on 9/3/10 7:51 AM.
Yeah, that is correct. You must disable those properties and you can't do that in portal-ext.properties. When using TerracottaJobStore it will throw errors if those properties are present.
Posted on 9/3/10 8:20 AM in reply to Sampsa Sohlman.
Thanks for the excellent post.

I have come across a problem where the Terracotta client log shows:


2010-09-09 14:14:29,874 [ConnectionEstablisher] WARN com.tc.net.protocol.transport.ClientMessageTransport - ConnectionID(1.50c199aa5ce84e0ca28d03b4e6e5d99d): Timeout of 10000 milliseconds occured [lossy interval: 10000ms]
2010-09-09 14:14:29,907 [L1_L2:TCComm Main Selector Thread_R (listen 0:0:0:0:0:0:0:0:53896)] WARN com.tc.net.protocol.transport.ClientMessageTransport - ConnectionID(1.50c199aa5ce84e0ca28d03b4e6e5d99d): CLOSE EVENT : com.tc.net.core.TCConnectionJDK14@775009342: connected: false, closed: true local=127.0.0.1:60631 remote=127.0.0.1:9510 connect=[Thu Sep 09 14:14:19 GMT 2010] idle=10015ms [0 read, 84 write]. STATUS : START
2010-09-09 14:14:29,908 [L1_L2:TCComm Main Selector Thread_R (listen 0:0:0:0:0:0:0:0:53896)] WARN com.tc.net.protocol.transport.ClientMessageTransport - ConnectionID(1.50c199aa5ce84e0ca28d03b4e6e5d99d): closing down connection - com.tc.net.core.TCConnectionJDK14@775009342: connected: false, closed: true local=127.0.0.1:60631 remote=127.0.0.1:9510 connect=[Thu Sep 09 14:14:19 GMT 2010] idle=10038ms [0 read, 84 write]
2010-09-09 14:14:30,881 [ConnectionEstablisher] INFO com.tc.net.protocol.transport.ClientMessageTransport - ConnectionID(1.50c199aa5ce84e0ca28d03b4e6e5d99d): Attaching new connection: com.tc.net.core.TCConnectionJDK14@425034011: connected: true, closed: false local=127.0.0.1:60633 remote=127.0.0.1:9510 connect=[Thu Sep 09 14:14:30 GMT 2010] idle=5ms [0 read, 0 write]

and the Terracotta console show:

2010-09-09 15:23:22,431 INFO - "Client Cannot Reconnect ConnectionID(0.50c199aa5ce84e0ca28d03b4e6e5d99d) not found. Connection attempts from the Terracotta node at 127.0.0.1:48718 are being rejected by the Terracotta server array. Restart the Client to allow it to rejoin the cluster. Many Client reconnection failures can be avoided by configuring the Terracotta server array for "permanent-store" and tuning reconnection parameters. For more information, see http://www.terracotta.org/kit/reflector?kitID=default&pageID=HA"

I have tried it with persistence set to "permanent-store" and it made no difference.

Any advice would be much appreciated.
Posted on 9/9/10 7:17 AM.
Hmm. I've usually seen this if Terracotta server is restarted while Liferay is running. Like the error message suggest you might need to tune the reconnection timeout settings. If you have not restarted your Terracotta server then there might have been some sort of network outage. If the problem persists I would ask help from Terracotta forums describing your setup and providing your tc-config.xml.
Posted on 9/9/10 7:31 AM in reply to Stuart Hirst.
Hello again Mika. I'm sorry to ask this question again but I have followed these instructions to the letter with two completely fresh installs and I'm still getting the same errors I indicated earlier. I agree with your assessment but as far as I can tell, I haven't done anything to tell single-vm cache to use Terracotta. Can you give me some more guidance on how this might have happened and how to isolate it as it seems improbable that this would happen without me messing it up somehow but I can't figure out how? To be clear this is a fresh install and the only things in portal-ext.properties are the mysql parameters and the entries from your post. The my-ehcache folder only contains the two files downloaded from your post with the terracottaConfig url parameter updated so.
Posted on 9/9/10 8:21 PM in reply to James Denmark.
Hello do you successfully run clustered liferay portal 6 without terracotta but with "basic" configuration of ehcache and jgroups ?
Posted on 9/10/10 2:16 AM in reply to James Denmark.
Mika, Thanks for your advice.

I have managed to address the problem by adding the following into tc-properties in the terracotta config:

<property name="l2.l1reconnect.enabled" value="true" />
<property name="l2.l1reconnect.timeout.millis" value="600000" />

Unfortunatly I am now experiencing the same problem as James Denmark below. I will add to that issue next.

Thanks again Stuart
Posted on 9/10/10 2:17 AM in reply to Mika Koivisto.
Have you done this setup with everything on one physical server or do you have separate servers for each Liferay and Terracotta? I will do some experimenting to try to reproduce that issue.
Posted on 9/10/10 2:23 AM in reply to James Denmark.
I am also experiencing the same problem. I orginally had timeout issues with Terracotta which I resolved with Mika's help.

I have tried this with both Liferay and Terracotta running both on a single host and have tried with Terracotta server on a separate host with the same results. The output from catalina.out shows :
Starting Liferay Portal Community Edition 6.0.5 CE (Bunyan / Build 6005 / August 16, 2010)
09:54:22,225 ERROR [velocity:151] ResourceManager.getResource() load exception
09:54:22,227 ERROR [velocity:151] net.sf.ehcache.CacheException: java.io.NotSerializableException: org.apache.velocity.Template
at org.terracotta.modules.ehcache.store.ValueModeHandlerSerialization.createTimesta­mpedValue(ValueModeHandlerSerialization.java:56)
etc.......
Posted on 9/10/10 2:30 AM in reply to James Denmark.
So the first time around I had a working ehcache cluster for sessions and document library when Mika's posting came out so I converted that and ran into the problem I originally posted. After Mika's response, I assumed there might be some complicating factor from my original config so I created new installs from scratch but ran into the same issue. The common element in both configurations was the Terracotta server.
Posted on 9/10/10 7:23 AM in reply to Eric Grandjean.
These were separate servers - two Centos/Tomcat/Liferay - one Centos/Terracotta.
Posted on 9/10/10 7:24 AM in reply to Mika Koivisto.
James, did you manage to resolve the java.io.NotSerializableException issue ? I have been trying various configurations without success and I am approaching the point where I will need to choose a different solution.

Any feedback would be useful. Thanks, Stuart
Posted on 9/14/10 12:52 AM in reply to James Denmark.
No. I still haven't resolved it and have moved onto other parts of my configuration hoping to get an update from Mika's test in the interim. Hoping to see an update soon as I am sure this must be something simple in the cache configuration and I too need to get this working or choose an alternative. If I uncover anything new I will post it.
Posted on 9/14/10 6:18 AM in reply to Stuart Hirst.
Hey Guys, sorry it took so long but I've now been able to reproduce your issue. It's caused by the use of MultiVMPoolUtil in com.liferay.portal.velocity.LiferayResourceCacheUtil. If you switch it to SingleVMPoolUtil you should be able to get past that error. Now this will reintroduce the issue described in http://issues.liferay.com/browse/LPS-8105.
Posted on 9/16/10 7:42 AM in reply to James Denmark.
Thanks for looking into this Mika.

To make sure I'm understanding this correctly. I run an 'out-of-the-box' Liferay instalation so I can't use Terracotta with Liferay 6 unless I customize the portal core as suggested above and run it in the EXT environment. Is that right?
Posted on 9/16/10 8:15 AM in reply to Mika Koivisto.
That is correct.
Posted on 9/16/10 8:17 AM in reply to James Denmark.
Its good, Thank you, Mika.
Posted on 10/20/10 1:48 AM.
Hi Mika,

i am also facing the above problem(java.io.NotSerializableException).can you please give any suggestions?

Caused by: java.io.notserializableexception org.apache.velocity.Template
Posted on 10/20/10 1:57 AM in reply to Narasimha Rao.
Hi Mike,

I am also facing the problem, can you plese let me know what changes to be made.

Thanks in Advance.
RK
Posted on 12/12/10 11:06 PM in reply to Mika Koivisto.
The serializable problem might have been fixed in trunk, have a look at
http://issues.liferay.com/browse/LPS-13429
Posted on 1/26/11 5:34 AM in reply to satish M.
I can't get this to work. Using a plain liferay-tomcat-6.0.5 bundle with mysql and the latest build of terracotta. I don't know if we have to configure terracotta but we have just started as described above and it seems to start ok but when we start liferay we keep getting the following in the logs.

2011-02-08 10:42:03,847 INFO - Terracotta 3.4.1, as of 20110130-210115 (Revision 17072 by cruise@su10mo4 from 3.4)
2011-02-08 10:42:04,716 INFO - Successfully loaded base configuration from server at 'localhost:9510'.
2011-02-08 10:42:04,773 INFO - Successfully loaded base configuration from file at '/liferay/liferay-portal-6.0.5/tomcat-6.0.26/temp/tc-config29604913327303$
2011-0­2-08 10:42:04,993 INFO - Log file: '/root/terracotta/client-logs/terracotta-client.log'.
2011-02-08 10:42:07,242 INFO - Connection successfully established to server at 192.168.1.169:9510
10:42:36,467 INFO [PortalImpl:277] Global lib directory /liferay/liferay-portal-6.0.5/tomcat-6.0.26/lib/ext/
10:42:36,469 INFO [PortalImpl:297] Portal lib directory /liferay/liferay-portal-6.0.5/tomcat-6.0.26/webapps/ROOT/WEB-INF/lib/
10:42:57,86­9 ERROR [QuartzSchedulerEngineImpl:73] Unable to initialize engine
java.lang.RuntimeException: Problem obtaining node id from TerracottaJobStore.
at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1180)
at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1465)
at com.liferay.portal.scheduler.quartz.QuartzSchedulerEngineImpl.afterPropertiesSet­(QuartzSchedulerEngineImpl.java:70)

Can any help.
Thanks
Keith
Posted on 2/8/11 5:00 AM.
Hi Mika,

I am getting following error while integrating liferay 6 sp1 to terracotta 3.6 :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'counterHibernateSessionFactory' defined in class path resource [META-INF/hibernate-spring.xml]: Invocation of init method failed; nested except
heManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.

Please help me to resolve this.
Posted on 4/12/12 11:17 PM.
Storing the session in terracotta works fine but the cache doesnt work.


08:01:44,701 ERROR [ContextLoader:220] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'asyncAdvice' while setting bean property 'nextMethodInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'asyncAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'threadLocalCacheAdvice' while setting bean property 'nextMethodInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'threadLocalCacheAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'bufferedIncrementAdvice' while setting bean property 'nextMethodInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bufferedIncrementAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'transactionAdvice' while setting bean property 'nextMethodInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'liferayTransactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferayTransactionManager' defined in class path resource [META-INF/hibernate-spring.xml]: Cannot resolve reference to bean 'liferayHibernateSessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferayHibernateSessionFactory' defined in class path resource [META-INF/hibernate-spring.xml]: Invocation of init method failed; nested exception is org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: Error configuring from null. Initial cause was null
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveRef­erence(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveVal­ueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.app­lyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.pop­ulateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC­reateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre­ateBean(AbstractAutowireCapableBeanFactory.java:456)
Posted on 5/30/12 1:24 AM.
Are there any plans to update/post instructions for integrating Liferay 6.1 with Terracotta? I tried to execute using the instructions above with Liferay 6.1 EE, however, I wound up getting the same error that Ankit reported above. It seems that the hibernate-spring initialization attempts to create the same caches that are created by the hibernate-terracotta Ehcache configuration. For reference, I used the XML files stored in the 6.1 EE portal-impl.jar rather than the files referenced above; they seem to be largely similar, but I figured that it'd be safer to stick with the ones that are distributed within EE.
Posted on 6/28/12 7:48 AM.
[...] I have 2 server. - Server1: OS is Ubuntu server 10.04 LTS. Run Liferay Portal 6.1 CE. (IP: 192.168.2.60) java version "1.6.0_20" OpenJDK Runtime Environment (IcedTea6 1.9.13)... [...] Read More
Posted on 7/3/12 10:08 PM.
Not work with Liferay 6.1 emoticon
Posted on 7/4/12 5:30 AM.
To solve the above problem, in portal-ext.properties ("EhCache and Hibernate Second Level Cache", step 7)
replace

hibernate.cache.region.factory_class=net.sf.ehcache.hibernate.EhCacheR­egionFactory
with
hibernate.cache.region.factory_class=net.sf.ehcache.hibernate.Si­ngletonEhCacheRegionFactory
Posted on 8/21/13 2:42 AM in reply to Ankit Srivastava.
[...] In our project based o Liferay running on Tomcat7 we use Terracotta. During Tomcat restart we got Terracotta exception: 15:38:54,281 ERROR [CacheFilter:59] net.sf.ehcache.CacheException:... [...] Read More
Posted on 11/20/13 8:42 AM.
Hi All

I am facing the issue when integrating terracotta with liferay-portal-6.2.10.1-ee-ga1

I am followed the Mika Blog http://www.liferay.com/web/mika.koivisto/blog/-/blogs/how-do-i-cluster-liferay-w­ith-terracotta-

The below is the error I am getting, Request you to please help me here.

2014-05-17 16:48:54,417 INFO – Connection successfully established to server at 192.168.0.100:9510
16:48:55,350 INFO [localhost-startStop-1][ValueModeHandlerFactory:125] Hibernate types found on the classpath : Enabling Hibernate value mode optimizations
16:48:55,912 INFO [localhost-startStop-1][ClusteredStore:125] Cache [com.liferay.portal.model.impl.UserImpl] using concurrency: 256
16:49:09,032 ERROR [localhost-startStop-1][ContextLoader:206] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.liferay.portal.kernel.cache.MultiVMPool’ defined in class path resource [META-INF/util-spring.xml]: Cannot resolve reference to bean ‘com.liferay.portal.kernel.cache.MultiVMPortalCacheManager’ while setting bean property ‘portalCacheManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.liferay.portal.kernel.cache.MultiVMPortalCacheManager’ defined in class path resource [META-INF/util-spring.xml]: Cannot create inner bean ‘com.liferay.portal.cache.ehcache.EhcachePortalCacheManager#704fb2′ of type [com.liferay.portal.cache.ehcache.EhcachePortalCacheManager] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.liferay.portal.cache.ehcache.EhcachePortalCacheManager#704fb2′ defined in class path resource

Caused by: java.lang.NoSuchFieldException: statisticsExecutor
at java.lang.Class.getDeclaredField(Class.java:1948)
at com.liferay.portal.kernel.util.ReflectionUtil.getDeclaredField(ReflectionUtil.ja­va:66)
at com.liferay.portal.cache.ehcache.CacheManagerUtil.<clinit>(CacheManagerUtil.java­:90)
… 52 more
Posted on 5/24/14 5:35 AM.
Hi there,

I currently try to integrate terracotta-4.3.0 with liferay-portal-tomcat-6.2-ce-ga2 following this post:
* I've upgraded ehcache-2.10.0.jar slf4j and added terracotta-toolkit-runtime-4.3.0.jar to the ROOT/WEB-INF/lib
* configured liferay hibernate-clustered.xml + liferay-multi-vm-clustered.xml for terracotta
* modified portal-ext.properties to use terracotta cache configuration

The terracotta client connexion works fine:

2015-05-27 17:12:25,973 INFO - Terracotta 4.3.0, as of 20150402-130831 (Revision 26225 from 4.3.0)
2015-05-27 17:12:26,533 INFO - Successfully loaded base configuration from server at 'localhost:9510'.
2015-05-27 17:12:26,566 INFO - Log file: '/home/foo/terracotta/client-logs/terracotta-client.log'.
2015-05-27 17:12:27,882 INFO - Connection successfully established to server at 127.0.1.1:9510
2015-05-27 17:12:45,049 INFO - Terracotta 4.3.0, as of 20150402-130831 (Revision 26225 from 4.3.0)
2015-05-27 17:12:45,414 INFO - Successfully loaded base configuration from server at 'localhost:9510'.
2015-05-27 17:12:45,438 INFO - Log file: '/home/foo/terracotta/client-logs/terracotta-client.log'.
2015-05-27 17:12:45,954 INFO - Connection successfully established to server at 127.0.1.1:9510

but I have a classloader issue in deserialization process on a cached class in a portlet (not the ROOT webapp), here is the stack:

Caused by: net.sf.ehcache.CacheException: Uncaught exception in get() - java.lang.ClassNotFoundException: foo.bar.liferay.model.impl.StructureSiteCacheModel
at org.terracotta.modules.ehcache.store.ClusteredSafeStore.get(ClusteredSafeStore.j­ava:236)
at org.terracotta.modules.ehcache.store.nonstop.NonStopStoreWrapper.get(NonStopStor­eWrapper.java:792)
at net.sf.ehcache.Cache.get(Cache.java:1751)
at net.sf.ehcache.Cache.get(Cache.java:1724)
at com.liferay.portal.cache.ehcache.EhcachePortalCache.get(EhcachePortalCache.java:­64)
at com.liferay.portal.cache.transactional.TransactionalPortalCache.get(Transactiona­lPortalCache.java:66)
at com.liferay.portal.dao.orm.common.EntityCacheImpl.loadResult(EntityCacheImpl.jav­a:188)
at com.liferay.portal.kernel.dao.orm.EntityCacheUtil.loadResult(EntityCacheUtil.jav­a:59)
at com.liferay.portal.dao.orm.common.FinderCacheImpl._primaryKeyToResult(FinderCach­eImpl.java:273)
at com.liferay.portal.dao.orm.common.FinderCacheImpl.getResult(FinderCacheImpl.java­:135)
at com.liferay.portal.kernel.dao.orm.FinderCacheUtil.getResult(FinderCacheUtil.java­:47)
at foo.bar.liferay.service.persistence.StructureSitePersistenceImpl.fetchByUai(Stru­ctureSitePersistenceImpl.java:686)
at foo.bar.liferay.service.persistence.StructureSitePersistenceImpl.fetchByUai(Stru­ctureSitePersistenceImpl.java:667)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at­ sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav­a:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils­.java:320)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(Ref­lectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM­ethodInvocation.java:150)
at com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice.invoke(ShardPersisten­ceAdvice.java:54)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM­ethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInv­ocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM­ethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.j­ava:202)
at com.sun.proxy.$Proxy473.fetchByUai(Unknown Source)
at foo.bar.liferay.service.impl.StructureSiteLocalServiceImpl.fetchByUai(StructureS­iteLocalServiceImpl.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at­ sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav­a:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMet­hodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(Default­TransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionI­nterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMet­hodInvocation.java:111)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.jav­a:175)
at com.sun.proxy.$Proxy472.fetchByUai(Unknown Source)
at foo.bar.liferay.service.StructureSiteLocalServiceUtil.fetchByUai(StructureSiteLo­calServiceUtil.java:278)
at foo.bar.utils.PersonUtils.getStructuresSites(PersonUtils.java:187)
at foo.bar.utils.AtriumPortletUtils.canCreateSubSite(AtriumPortletUtils.java:277)
a­t org.apache.jsp.html.portlet.dockbar.view_jsp._jspService(view_jsp.java:1224)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
­... 182 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: foo.bar.liferay.model.impl.StructureSiteCacheModel
at com.terracotta.toolkit.collections.map.ServerMap.deserialize(ServerMap.java:389)­
at com.terracotta.toolkit.collections.map.ServerMap.deserialize(ServerMap.java:369)­
at com.terracotta.toolkit.collections.map.ServerMap.getNonExpiredValue(ServerMap.ja­va:324)
at com.terracotta.toolkit.collections.map.ServerMap.doGet(ServerMap.java:264)
at com.terracotta.toolkit.collections.map.ServerMap.get(ServerMap.java:1274)
at com.terracotta.toolkit.collections.map.AggregateServerMap.get(AggregateServerMap­.java:395)
at com.terracotta.toolkit.collections.map.ToolkitCacheImpl.get(ToolkitCacheImpl.jav­a:251)
at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav­a:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.terracotta.toolkit.nonstop.NonStopInvocationHandler.invokeMethod(NonStopInvo­cationHandler.java:154)
at com.terracotta.toolkit.nonstop.NonStopInvocationHandler.invoke(NonStopInvocation­Handler.java:54)
at com.sun.proxy.$Proxy19.get(Unknown Source)
at org.terracotta.modules.ehcache.store.ClusteredStore.get(ClusteredStore.java:316)­
at org.terracotta.modules.ehcache.store.ClusteredSafeStore.get(ClusteredSafeStore.j­ava:229)
... 225 more

Does anyone experienced this before ? any Idea ?

thanx.
Posted on 5/27/15 8:33 AM in reply to Hari babu.
Hello Sébastien: have you been able to solve your issue?
In my architecture, I have a Liferay 6.2 EE cluster (probably 6 nodes) that I want to connect to a Terracotta 4.3.1 cluster. However, because of the previous feedbacks I read in this blog, I just wonder if it is relevant to propose a Terracotta cluster.
Any idea?
Posted on 4/5/16 8:14 AM in reply to Sébastien LEVER.
The correct answer is it depends. For example if they are geographically distributed in different data centers it might be relevant. If they are all in the same DC then Liferay ClusterLink enabled cache is probably sufficient. In order to get supported Terracotta + Liferay EE you'll need Liferay EE Terracotta Edition.
Posted on 4/5/16 8:21 AM in reply to Van Tuan DANG.
Thank you Mika for this quick answer.
The issue of using ClusterLink is that my caches will be replicated what decreases the horizontal scalability of my architecture. I found it interesing to have a central cache solution in order to prevent caches and sessions replications.
Are there alternatives cache solutions to Terracotta ?
Posted on 4/5/16 9:00 AM in reply to Mika Koivisto.
Don't use cache replication for Liferay caches. It won't give you any performance increase but rather causes issues with stale data that is unless you use Terracotta. So far I've seen Terracotta is the best solution where you need cohesive replicated cache.

Sticky session and cache invalidation instead of replication is the best way to go as far as Liferay is concerned. For your custom apps it might be different.
Posted on 4/5/16 9:12 AM in reply to Van Tuan DANG.
Hi Van Tuan, I finaly use ClusterLInk in my CE cluster (6.2GA5) multicast mode with stickySession and cache invalidation over 2 nodes according to Mika recommendations. And it works fine ;)
Posted on 4/5/16 1:03 PM in reply to Van Tuan DANG.
Thank you for your replies Mika, Sébastien.
I will try your recommendations and let you know whether it also works fine in my case.
Posted on 4/5/16 11:38 PM in reply to Sébastien LEVER.