Foren
MultiVMPool cache in Liferay 6.2
Giang Nguyen, geändert vor 10 Jahren.
MultiVMPool cache in Liferay 6.2
New Member Beiträge: 4 Beitrittsdatum: 16.09.13 Neueste Beiträge
Hi all,
In LR 6.0, I set the cache by MultiVMPoolUtil by this:
But in LR 6.2, when I deploy sample portlet with MultiVMPoolUtil.put() method, server throws these exception:
when I looking in the source code of LR, I can not find put method. So how can I set cache by MultiVMPool in LR 6.2?
Thank you.
In LR 6.0, I set the cache by MultiVMPoolUtil by this:
MultiVMPoolUtil.put("Cache-name", "key" ,"value");
But in LR 6.2, when I deploy sample portlet with MultiVMPoolUtil.put() method, server throws these exception:
Caused by: java.lang.NoSuchMethodError: com.liferay.portal.kernel.cache.MultiVMPoolUtil.put(Ljava/lang/String;Ljava/lang/String;Ljava/io/Ser
ializable;)V
when I looking in the source code of LR, I can not find put method. So how can I set cache by MultiVMPool in LR 6.2?
Thank you.
Juan Gonzalez, geändert vor 10 Jahren.
RE: MultiVMPool cache in Liferay 6.2
Liferay Legend Beiträge: 3089 Beitrittsdatum: 28.10.08 Neueste Beiträge
i Giang,
guess what you need is:
guess what you need is:
MultiVMPoolUtil.getCache("yourCacheName").put(key, value)
Giang Nguyen, geändert vor 10 Jahren.
RE: MultiVMPool cache in Liferay 6.2
New Member Beiträge: 4 Beitrittsdatum: 16.09.13 Neueste Beiträge
Hi Juan,
Thanks for your support. After I used your recommend code, I got new no method exception with method put() in PortalCache package.
I found put() in source code of LR 6.2, but I dont know why it throw exception.
Do you have any solution for this?
Thanks for your support. After I used your recommend code, I got new no method exception with method put() in PortalCache package.
Caused by: java.lang.NoSuchMethodError: com.liferay.portal.kernel.cache.PortalCache.put(Ljava/io/Serializable;Ljava/io/Serializable;)V
I found put() in source code of LR 6.2, but I dont know why it throw exception.
Do you have any solution for this?
Antoine Comble, geändert vor 10 Jahren.
RE: MultiVMPool cache in Liferay 6.2
Regular Member Beiträge: 232 Beitrittsdatum: 07.09.12 Neueste Beiträge
Hi,
You should read the api : http://grepcode.com/file/repo1.maven.org/maven2/com.liferay.portal/portal-service/6.2.0/com/liferay/portal/kernel/cache/BlockingPortalCache.java?av=f
At line 111, the code is _portalCache.put(key, value).
On mouseover, you could read the value parameter expected must be java.lang.Object.
Hope this help you,
Regards,
Antoine
You should read the api : http://grepcode.com/file/repo1.maven.org/maven2/com.liferay.portal/portal-service/6.2.0/com/liferay/portal/kernel/cache/BlockingPortalCache.java?av=f
At line 111, the code is _portalCache.put(key, value).
On mouseover, you could read the value parameter expected must be java.lang.Object.
Hope this help you,
Regards,
Antoine
Giang Nguyen, geändert vor 10 Jahren.
RE: MultiVMPool cache in Liferay 6.2
New Member Beiträge: 4 Beitrittsdatum: 16.09.13 Neueste Beiträge
Hi Antoine,
I read the api already and I thought we can put a pair <key,value> with any value. Because java.lang.Object is the root of any type in java, included String, right?
One more thing the put() method we are talking is come from PortalCache.java, not BlockingPortalCache.java. So i dont think this is problem.
I read the api already and I thought we can put a pair <key,value> with any value. Because java.lang.Object is the root of any type in java, included String, right?
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
One more thing the put() method we are talking is come from PortalCache.java, not BlockingPortalCache.java. So i dont think this is problem.
Antoine Comble, geändert vor 10 Jahren.
RE: MultiVMPool cache in Liferay 6.2
Regular Member Beiträge: 232 Beitrittsdatum: 07.09.12 Neueste Beiträge
PortalCache is an interface and BlockingPortalCache implements it.
It was for an example of use of PortalCache.put method.
You're right. If String cannot put as value, this is not the problem.
Antoine
It was for an example of use of PortalCache.put method.
You're right. If String cannot put as value, this is not the problem.
Antoine
Tushar Patel, geändert vor 8 Jahren.
RE: MultiVMPool cache in Liferay 6.2
New Member Beiträge: 12 Beitrittsdatum: 26.08.14 Neueste BeiträgeAntoine Comble:
PortalCache is an interface and BlockingPortalCache implements it.
It was for an example of use of PortalCache.put method.
You're right. If String cannot put as value, this is not the problem.
Antoine
Hi Antoine
Can you put little snippet for put the catche? Earlier we are using MultiVMPoolUtil.put() method. Thanks
archana thakur, geändert vor 7 Jahren.
RE: MultiVMPool cache in Liferay 6.2
Junior Member Beiträge: 27 Beitrittsdatum: 13.03.12 Neueste Beiträge
Hi Gonzalez ,
I am upgrading liferay 6.1 to 6.2
instead of this
MultiVMPoolUtil.put(cacheName, key, cacheObj);
I am using this method
String kv = (String)MultiVMPoolUtil.getCache(cacheName);
MultiVMPoolUtil.getCache("CacheName").put(key, kv);
its giving me compilation error
incompatible types: PortalCache<Serializable,Serializable> cannot be converted to String
can you please help me or anyone is resolve this issue.
Thanks
Archana
I am upgrading liferay 6.1 to 6.2
instead of this
MultiVMPoolUtil.put(cacheName, key, cacheObj);
I am using this method
String kv = (String)MultiVMPoolUtil.getCache(cacheName);
MultiVMPoolUtil.getCache("CacheName").put(key, kv);
its giving me compilation error
incompatible types: PortalCache<Serializable,Serializable> cannot be converted to String
can you please help me or anyone is resolve this issue.
Thanks
Archana
Juan Gonzalez, geändert vor 7 Jahren.
RE: MultiVMPool cache in Liferay 6.2
Liferay Legend Beiträge: 3089 Beitrittsdatum: 28.10.08 Neueste Beiträgearchana thakur:
its giving me compilation error
incompatible types: PortalCache<Serializable,Serializable> cannot be converted to String
can you please help me or anyone is resolve this issue.
Thanks
Archana
getCache doesn't return a String object, but a PortalCache object. You sould change that.
archana thakur, geändert vor 7 Jahren.
RE: MultiVMPool cache in Liferay 6.2
Junior Member Beiträge: 27 Beitrittsdatum: 13.03.12 Neueste Beiträge
Hi Gonzalez
now I make change this
PortalCache cache = MultiVMPoolUtil.getCache("cacheName");
its giving me error message
CacheUtil.java:[113,2] error: cannot find symbol
Thanks
Archana
now I make change this
PortalCache cache = MultiVMPoolUtil.getCache("cacheName");
its giving me error message
CacheUtil.java:[113,2] error: cannot find symbol
Thanks
Archana
Juan Gonzalez, geändert vor 7 Jahren.
RE: MultiVMPool cache in Liferay 6.2
Liferay Legend Beiträge: 3089 Beitrittsdatum: 28.10.08 Neueste Beiträgearchana thakur:
Hi Gonzalez
now I make change this
PortalCache cache = MultiVMPoolUtil.getCache("cacheName");
its giving me error message
CacheUtil.java:[113,2] error: cannot find symbol
Thanks
Archana
Sorry I think there are missing info there, paste complete error.
You probably forgot to import some packages for that code.
archana thakur, geändert vor 7 Jahren.
RE: MultiVMPool cache in Liferay 6.2
Junior Member Beiträge: 27 Beitrittsdatum: 13.03.12 Neueste Beiträge
Hi Juan,
After make this API changes we are facing one other issue in Liferay 6.2.1 EE .
ehcache class is not loading , we have try to loading this class with different version but no success .
net.sf.ehcache.CacheException:
Unable to load class net.sf.ehcache.store.DefaultElementValueComparator.
Initial cause was net.sf.ehcache.store.DefaultElementValueComparator.<
init>(net.sf.ehcache.config.CacheConfiguration)
at net.sf.ehcache.util.ClassLoaderUtil.createNewInstance(ClassLoaderUtil.java:100)
at net.sf.ehcache.config.ElementValueComparatorConfiguration.createElementComparatorInstance(ElementValueComparatorConfiguration.java:57)
at net.sf.ehcache.Cache.<init>(Cache.java:791)
at net.sf.ehcache.Cache.clone(Cache.java:2761)
at net.sf.ehcache.Cache.clone(Cache.java:163)
at net.sf.ehcache.CacheManager.cloneDefaultCache(CacheManager.java:1945)
at net.sf.ehcache.CacheManager.addCache(CacheManager.java:1218)
Regards
Archana
After make this API changes we are facing one other issue in Liferay 6.2.1 EE .
ehcache class is not loading , we have try to loading this class with different version but no success .
net.sf.ehcache.CacheException:
Unable to load class net.sf.ehcache.store.DefaultElementValueComparator.
Initial cause was net.sf.ehcache.store.DefaultElementValueComparator.<
init>(net.sf.ehcache.config.CacheConfiguration)
at net.sf.ehcache.util.ClassLoaderUtil.createNewInstance(ClassLoaderUtil.java:100)
at net.sf.ehcache.config.ElementValueComparatorConfiguration.createElementComparatorInstance(ElementValueComparatorConfiguration.java:57)
at net.sf.ehcache.Cache.<init>(Cache.java:791)
at net.sf.ehcache.Cache.clone(Cache.java:2761)
at net.sf.ehcache.Cache.clone(Cache.java:163)
at net.sf.ehcache.CacheManager.cloneDefaultCache(CacheManager.java:1945)
at net.sf.ehcache.CacheManager.addCache(CacheManager.java:1218)
Regards
Archana