留言板

Classloading issue in 6.2 beta3 with ehcache?

donino donino,修改在10 年前。

Classloading issue in 6.2 beta3 with ehcache?

Junior Member 帖子: 81 加入日期: 11-7-2 最近的帖子
Hi,

My portlet application ships with ehcache in WEB-INF/lib. It did not cause any trouble with liferay 5+,6.0+,6.1+, and it still works with 6.2.M6 version.

However with 6.2 beta3 (Tomcat 7 bundle), we run into this problem when trying to get user attributes from a PortletRequest:


10:50:08,081 ERROR [http-bio-8080-exec-10][UserAttributes:92] 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)
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)
at com.liferay.portal.cache.ehcache.EhcachePortalCacheManager.addCache(EhcachePortalCacheManager.java:233)
at com.liferay.portal.cache.ehcache.EhcachePortalCacheManager.getCache(EhcachePortalCacheManager.java:133)
at com.liferay.portal.cache.MultiVMPoolImpl.getCache(MultiVMPoolImpl.java:47)
at sun.reflect.GeneratedMethodAccessor135.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
at com.sun.proxy.$Proxy24.getCache(Unknown Source)
at com.liferay.portal.dao.orm.common.FinderCacheImpl._getPortalCache(FinderCacheImpl.java:231)
at com.liferay.portal.dao.orm.common.FinderCacheImpl.getResult(FinderCacheImpl.java:120)
at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
at com.sun.proxy.$Proxy31.getResult(Unknown Source)
at com.liferay.portal.kernel.dao.orm.FinderCacheUtil.getResult(FinderCacheUtil.java:47)
at com.liferay.portal.service.persistence.AddressPersistenceImpl.findByC_C_C(AddressPersistenceImpl.java:2792)
at com.liferay.portal.service.persistence.AddressPersistenceImpl.findByC_C_C(AddressPersistenceImpl.java:2728)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
at com.sun.proxy.$Proxy100.findByC_C_C(Unknown Source)
at com.liferay.portal.service.impl.AddressLocalServiceImpl.getAddresses(AddressLocalServiceImpl.java:153)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:117)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:52)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:186)
at com.liferay.portal.security.pacl.PACLInvocationHandler.doInvoke(PACLInvocationHandler.java:62)
at com.liferay.portal.security.pacl.PACLInvocationHandler.invoke(PACLInvocationHandler.java:51)
at com.sun.proxy.$Proxy98.getAddresses(Unknown Source)
at com.liferay.portal.service.AddressLocalServiceUtil.getAddresses(AddressLocalServiceUtil.java:342)
at com.liferay.portal.model.impl.UserImpl.getAddresses(UserImpl.java:91)
at com.liferay.portlet.UserAttributes.<init>(UserAttributes.java:268)
at com.liferay.portlet.UserInfoFactory.getUserInfo(UserInfoFactory.java:90)
at com.liferay.portlet.UserInfoFactory.getUserInfo(UserInfoFactory.java:73)
at com.liferay.portlet.PortletRequestImpl.getUserInfo(PortletRequestImpl.java:519)
at com.liferay.portlet.PortletRequestImpl.getAttribute(PortletRequestImpl.java:152)


This exception is triggered when we try to access user attributes through THEME_DISPLAY, it always return null:
       Object oThemeDisplay=request.getAttribute(WebKeys.THEME_DISPLAY);
        if (oThemeDisplay!=null){
                //do stuff with expando bridge...
        }else{
              logger.log( Level.WARNING, "THEME_DISPLAY cannot be found in Liferay request attributes with key:{0}",WebKeys.THEME_DISPLAY);                    
        }


I am not entirely sure it is specific to the fact ehcache resides in WEB-INF/lib, but this classloading issue suggests it is related to a conflict with OSGi classloader.

Here is what i tried:
  • Use the same ehcache version 2.7.1 as Liferay 6.2 beta3 =>got the same exception
  • Remove ehcache from WEB-INF/lib, and add a dependency on ehcache in liferay-plugin-package.properties => got the same exception
  • Remove ehcache from WEB-INF/lib (ehcache not found by the app=>portlet could not start)


Is it a known issue, and is there a workaround for this?

Thanks!
thumbnail
Ray Augé,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Liferay Legend 帖子: 1197 加入日期: 05-2-8 最近的帖子
what are you using ehcache for in your plugin?
donino donino,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Junior Member 帖子: 81 加入日期: 11-7-2 最近的帖子
Ehcache is used to cache the result of reports generated with BIRT.

I can't reproduce this issue with a simple portlet app. After a Iong search i think it is probably due to the presence of Eclipse Equinox in the BIRT runtime, but i don't have any idea why it happens only from Liferay 6.2 beta 1. Can we still disable OSGi in 6.2, at least for testing purpose?

Contrary to my earlier belief, this very problem does not break the portlet application, the only consequence is we can't get user attributes from a portlet request.
I believed this, because it was the only Exception thrown but i found several much more nasty issues. I created another thread to summarize them, and joined a very simple portlet application allowing to reproduce these problems.

Thanks!
donino donino,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Junior Member 帖子: 81 加入日期: 11-7-2 最近的帖子
Hi,

I insist with this problem because i am quite sure there is something very, very nasty with ehcache and 6.2 beta. To illustrate this, on a fresh Liferay 6.2 beta3 we just have to copy ROOT/WEB-INF/lehcache.jar into WEB-INF/lib folder of an HelloWorld Portlet., or WEB-INF/lib on an existing portlet such calendar even if it does not make use of ehcache at all.

When we restart the portal it is completely broken with many exceptions such:

11:28:45,076 ERROR [localhost-startStop-1][HotDeployImpl:92] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering plugins for marketplace-portlet
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering plugins for marketplace-portlet
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:46)
at com.liferay.portal.deploy.hot.PluginPackageHotDeployListener.invokeDeploy(PluginPackageHotDeployListener.java:64)
at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:203)
at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
at com.sun.proxy.$Proxy34.fireDeployEvent(Unknown Source)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:164)
at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:154)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:44)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:64)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:56)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:54)
at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:116)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1672)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: 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)
at com.liferay.portal.cache.ehcache.EhcachePortalCacheManager.addCache(EhcachePortalCacheManager.java:233)
at com.liferay.portal.cache.ehcache.EhcachePortalCacheManager.getCache(EhcachePortalCacheManager.java:133)
at com.liferay.portal.cache.MultiVMPoolImpl.getCache(MultiVMPoolImpl.java:47)
at sun.reflect.GeneratedMethodAccessor136.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
at com.sun.proxy.$Proxy24.getCache(Unknown Source)
at com.liferay.portal.dao.orm.common.FinderCacheImpl._getPortalCache(FinderCacheImpl.java:231)
at com.liferay.portal.dao.orm.common.FinderCacheImpl.getResult(FinderCacheImpl.java:120)
at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
at com.sun.proxy.$Proxy31.getResult(Unknown Source)
at com.liferay.portal.kernel.dao.orm.FinderCacheUtil.getResult(FinderCacheUtil.java:47)
at com.liferay.portal.service.persistence.ServiceComponentPersistenceImpl.findByBuildNamespace(ServiceComponentPersistenceImpl.java:181)
at com.liferay.portal.service.persistence.ServiceComponentPersistenceImpl.findByBuildNamespace(ServiceComponentPersistenceImpl.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
at com.sun.proxy.$Proxy234.findByBuildNamespace(Unknown Source)
at com.liferay.portal.service.impl.ServiceComponentLocalServiceImpl.initServiceComponent(ServiceComponentLocalServiceImpl.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:117)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:52)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:186)
at com.liferay.portal.security.pacl.PACLInvocationHandler.doInvoke(PACLInvocationHandler.java:62)
at com.liferay.portal.security.pacl.PACLInvocationHandler.invoke(PACLInvocationHandler.java:51)
at com.sun.proxy.$Proxy233.initServiceComponent(Unknown Source)
at com.liferay.portal.service.ServiceComponentLocalServiceUtil.initServiceComponent(ServiceComponentLocalServiceUtil.java:285)
at com.liferay.portal.deploy.hot.PluginPackageHotDeployListener.initServiceComponent(PluginPackageHotDeployListener.java:241)
at com.liferay.portal.deploy.hot.PluginPackageHotDeployListener.doInvokeDeploy(PluginPackageHotDeployListener.java:126)
at com.liferay.portal.deploy.hot.PluginPackageHotDeployListener.invokeDeploy(PluginPackageHotDeployListener.java:61)
... 31 more
Caused by: java.lang.NoSuchMethodException: net.sf.ehcache.store.DefaultElementValueComparator.<init>(net.sf.ehcache.config.CacheConfiguration)
at java.lang.Class.getConstructor0(Class.java:2800)
at java.lang.Class.getConstructor(Class.java:1708)
at net.sf.ehcache.util.ClassLoaderUtil.createNewInstance(ClassLoaderUtil.java:91)
... 97 more

thumbnail
Ray Augé,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Liferay Legend 帖子: 1197 加入日期: 05-2-8 最近的帖子
It would appear what is happening is the ServiceBuilder architecture is being confused by the presence of the ehcache jar in the plugin.

When the plugin's service builder spring context is initialized, it's created using an "aggregate" classloader with the core portal

[plugin classloader, portal classloader]

(Note the plugin classloader is first, this is for obvious reasons.)

However, this is likely causing the initialization problems you are seeing due to the fact that a different version of the ehcache classes are found in the plugin rather than those of the portal which are expected.
y t,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 帖子: 2 加入日期: 13-5-30 最近的帖子
i took special care to ensure that the versions are the same.
i still have the same problem. so in practice ensuring same versions did not work emoticon
looking for other suggestions worth trying.
thank you.
donino donino,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Junior Member 帖子: 81 加入日期: 11-7-2 最近的帖子
I confirm. Most of my tests have been done with ehcache 2.7.1 from Maven repo, but i also tried with all versions from 2.6.3 to 2.7.2 it is the same.
I even tried with libraries which ship in Liferay ROOT/WEB-INF/lib:
- ehcache.jar (v2.7.1)
- ehcache-terracotta-bootstrap-2.7.1.jar
It didn't help. However I could not find a maven depency in Liferay source code for ehcache, so may be there are other jar that should be copied from ROOT/WEB-INF/lib to the plugin folder to make it work?

The root of the problem might be due to the fact that ehcache has its own classloading policy, as we can see in this code snippet. But i can't figure why this issue appeared only from 6.2 beta. Any suggestion will be much appreciated!
thumbnail
Ray Augé,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Liferay Legend 帖子: 1197 加入日期: 05-2-8 最近的帖子
When I said "different version" I should have said "different instance".

The cache entities of a Liferay service cross over into the portal core space. If the classes there didn't originate with that classLoader, then you will have classloader problems like these.

Does BIRT have it's own dependency on ehcache? or are you using it yourself to provide the cache tier? If you are using it yourself, you could eliminate that dependency by using Liferay's cache API instead.

If it's a dependency of BIRT itself, then you might have to isolate BIRT from an app which also contains ServiceBuilder entities, and use the just the API from your BIRT app.

It's not ideal I know. Not sure what else to suggest.
donino donino,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Junior Member 帖子: 81 加入日期: 11-7-2 最近的帖子
Thank you for the suggestion Ray, however this application runs on other portals so i would use Liferay's cache API in very last resort.

I think there is a solution. I summarize what we have:

- Something has changed in classloading between 6.2M6 and 6.2 beta: in 6.2 beta, ehcache is now loaded by the portal classloader, even if there is another instance in the plugin classloader
- Ehcache "resists" and because of this ClassLoaderUtil, some classes jump back to the plugin classloader, which leads to our bug. No doubt it is a bug of ehcache, it will probably be fixed in future versions but currently we have to deal with it.

We can prevent ehcache from jumping everywhere by modifying this ClassLoaderUtil. That's what i did: i changed the source and reversed the order so that
Thread.currentThread().getContextClassLoader();
does not have priority anymore. Then i replaced ClassLoaderUtil.class with this new one in ROOT/WEB-INF/lib/Ehcache.jar, and it solved everything!

Is it envisageable to submit this kind of patch, to update ehcache.jar in the distribution? is it possible to log an issue for this

Thanks
J. David Mendoza,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 帖子: 14 加入日期: 06-8-25 最近的帖子
Could you post the resulting ehcache.jar? I don't understand what needs to be changed on the ehcache's ClassLoaderUtil class...

Thanks...
donino donino,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Junior Member 帖子: 81 加入日期: 11-7-2 最近的帖子
Hi David,

Sorry for the delay, i give you my work on this subject: i joined the .class file and its source code.

To install it: stop the portal, rename ehcache.jar from Liferay distribution to ehcache.zip. In this zip file locate the ClassLoaderUtil.class file and replace it with the one i joined. Then rename ehcache.zip to ehcache.jar and restart the portal.

It does the job, though be careful this is a complex subject and we cant warrant there won't be side effects. I tried to get a response from Terracotta to know if this was the right implementation for their future versions but no luck, everyone is scared with classloading issues and nobody can answer emoticon

On my side i finally used a different approach to isolate ehcache, very complex but it avoids to change the ehcache.jar in Liferay libs. The best approach would probably be to use ehcache as an OSGI bundle in your application

Hope this helps
J. David Mendoza,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 帖子: 14 加入日期: 06-8-25 最近的帖子
No problem... Thanks a lot!

Will try it out... and see if it works...

Thanks again.
Tien Tran,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 发布: 1 加入日期: 13-11-10 最近的帖子
Guys,

Appreciate your patched class but it would be less intrusive to place it under ROOT/WEB-INF/classes which will be loaded first. I confirm this works for me.

Cheers,
Tien
donino donino,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Junior Member 帖子: 81 加入日期: 11-7-2 最近的帖子
Hi Tien,

You are definitely right, your solution is much smarter! But this issue turned me so crazy that i didn't want to give a single chance to this horrible class to be loaded twice or in a wrong priority order emoticon

regards
Brice Chaffangeon,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 帖子: 11 加入日期: 13-6-18 最近的帖子
Hi Liferay Guys,

Do have any cleaner solution for this issue ?
I have the same problem here on 6.2-GA1 (use case : I just want to use Ehcache 2.7.4 on my own, and facing same classloader issue).

I admit it's turning me crazy emoticon

Regards,
B C,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 帖子: 11 加入日期: 13-6-18 最近的帖子
I found a way :

Add this in liferay-plugin-package.properties :

portal-dependency-jars=\
ehcache.jar

And that's it...
thumbnail
Gordon Augat,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Regular Member 帖子: 107 加入日期: 06-8-16 最近的帖子
B C:
I found a way :

Add this in liferay-plugin-package.properties :

portal-dependency-jars=\
ehcache.jar

And that's it...


I have the same problem with 6.2-GA1, but the above solution did not work for me.
B C,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 帖子: 11 加入日期: 13-6-18 最近的帖子
Hi,

Indeed, the above solution doesn't work, sorry for that... emoticon

The only way is to follow Donino instructions :

To install it: stop the portal, rename ehcache.jar from Liferay distribution to ehcache.zip. In this zip file locate the ClassLoaderUtil.class file and replace it with the one i joined. Then rename ehcache.zip to ehcache.jar and restart the portal.
y t,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 帖子: 2 加入日期: 13-5-30 最近的帖子
+1 for a workaround as well, please/
P M,修改在10 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 发布: 1 加入日期: 14-3-19 最近的帖子
Try configure catalina.policy to allow all.

 grant {
     permission java.security.AllPermission;
 };


This configuration change solved problem for me.
thumbnail
Aliabbas Surti,修改在9 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 帖子: 11 加入日期: 13-5-7 最近的帖子
P M:
Try configure catalina.policy to allow all.

 grant {
     permission java.security.AllPermission;
 };


This configuration change solved problem for me.


Not sure you are talking about the same issue that is being discussed in this post emoticon!
Granger Guillaume,修改在9 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 帖子: 3 加入日期: 10-5-18 最近的帖子
Hi,

I have the same issue in Liferay 6.2 CE ga2, I try to follow the instructions for modifying the ehcache jar. But it's still doesn't works.

Thanks for replies.
Piotr Bogusz,修改在9 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 发布: 1 加入日期: 12-11-9 最近的帖子
Hi,
you can try update ehcache in Liferay to your version:

<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.9.0</version>
</dependency>

In my case this solution works.
thumbnail
Aliabbas Surti,修改在9 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

New Member 帖子: 11 加入日期: 13-5-7 最近的帖子
Hi Donino,

I am trying to upgrade my organisation's portlets from Liferay EE 6.1 to Liferay EE 6.2 GA1.

I have been having troubles with the same ehcache issue,

Caused by: 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)


I have tried your solution of changing the ClassLoaderUtil. Unfortunately, it has not worked for me. It doesn't even change the error.

I still don't have a clue why it is not working with Liferay EE 6.2. It worked perfectly on EE 6.1. I am going to try it on the latest Liferay 6.2 EE SP2 today. Hope it works.

I have raised the issue with Liferay and they have pointed me to - https://jira.terracotta.org/jira/browse/EHC-989 and suggested the following potential solution,

1. Go to $liferay_home/tomcat\webapps\ROOT\WEB-INF\classes\
2. Create the directory structure as net\sf\ehcache\util\ (the complete directory structure likes $liferay_home/tomcat\webapps\ROOT\WEB-INF\classes\net\sf\ehcache\util)
3. Copy the ClassLoaderUtil.class file in the attachment into $liferay_home/tomcat\webapps\ROOT\WEB-INF\classes\net\sf\ehcache\util\
4. Restart tomcat application, deploy war and the portlet will be deployed successfully.

It somehow worked for one of the portlet but is not for another. It was probably something else that made the earlier portlet work!

Cheers
donino donino,修改在9 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Junior Member 帖子: 81 加入日期: 11-7-2 最近的帖子
Hi Aliabbas,

I sympathize very much i know how awful this issue is emoticon

Does your portlet plugin ship with ehcache, or do you make use of a dependency in liferay-plugin-package.properties? If ehcache is embedded , ClassLoaderUtil.class should be updated here too, otherwise results would be (even more...) unpredictable.

But even if it worked, since Terracotta staff does not recommend this approach it wouldn't be an acceptable solution, unfortunately. On my side, i ended to load ehcache in a private ClassLoader using Reflection, so i was sure to get rid of this trouble once for all. That's complicated but it works very well. I envisage to implement a version taking advantage of Liferay cache API in the future, may be you should begin to have a look on it too

Cheers
ildar sl,修改在8 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Regular Member 帖子: 158 加入日期: 11-12-12 最近的帖子
The problem I have decided to liferay-portal-6.2-ce-ga4\tomcat-7.0.42\webapps\ROOT\WEB-INF\lib\ehcache.jar by overwriting a later version.
Download it here http://www.ehcache.org/downloads/
Ralf Haller,修改在7 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Junior Member 帖子: 54 加入日期: 13-5-13 最近的帖子
I noticed the described problem doesn't show up anymore in Liferay 6.2.5 GA6. I'm not sure about 6.2.4 GA5 though...

What has changed since GA4?

Ralf
thumbnail
Juan Gonzalez,修改在7 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Liferay Legend 帖子: 3089 加入日期: 08-10-28 最近的帖子
Ralf Haller:
I noticed the described problem doesn't show up anymore in Liferay 6.2.5 GA6. I'm not sure about 6.2.4 GA5 though...

What has changed since GA4?

Ralf


Ehcache had been upgraded.
Ralf Haller,修改在7 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Junior Member 帖子: 54 加入日期: 13-5-13 最近的帖子
I couldn't find anything in the release notes for GA5 and GA6. Is there a bug number available for this upgrade?

Ralf
thumbnail
Juan Gonzalez,修改在7 年前。

RE: Classloading issue in 6.2 beta3 with ehcache?

Liferay Legend 帖子: 3089 加入日期: 08-10-28 最近的帖子
You asked for GA4 to GA6 upgrade, not from GA5.

It was upgraded in GA5: https://issues.liferay.com/browse/LPS-48800