Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-3518

Redeploy of Liferay in weblogic 10.3 causes java.lang.NoClassDefFoundError: org/hibernate/cache/CacheException


    • Type: Bug
    • Status: Closed
    • Resolution: Inactive
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:
      Window XP and WebLogic 10.3 using sun jdk
    • Branch Version/s:


      The first deploy of Liferay on Web logic 10.3 is successful. A second deploy fails with the following stack trace.

      Sun JDK 1.6 stack trace
      weblogic.application.ModuleException: [HTTP:101216]Servlet: "Main Servlet" failed to preload on startup in Web application: "liferay-portal-5.2.2".
      java.lang.NoClassDefFoundError: org/hibernate/cache/CacheException
      at net.sf.ehcache.hibernate.EhCache.clear(EhCache.java:166)
      at com.liferay.portal.dao.orm.hibernate.CacheWrapper.invalidate(CacheWrapper.java:131)
      at com.liferay.portal.kernel.cache.CacheRegistry.clear(CacheRegistry.java:43)
      at com.liferay.portal.kernel.cache.CacheRegistry.setActive(CacheRegistry.java:72)
      at com.liferay.portal.events.StartupAction.doRun(StartupAction.java:122)
      at com.liferay.portal.events.StartupAction.run(StartupAction.java:75)
      at com.liferay.portal.servlet.MainServlet.init(MainServlet.java:154)

      Jrocket creates stack trace similar to this.
      java.lang.NoSuchMethodError: org.hibernate.cache.CacheException.<init>(Ljava/lang/Exception;)V
      at net.sf.ehcache.hibernate.EhCache.clear(EhCache.java:166)
      at com.liferay.portal.dao.orm.hibernate.CacheWrapper.invalidate(CacheWrapper.java:132)
      at com.liferay.portal.kernel.cache.CacheRegistry.clear(CacheRegistry.java:43)

      I tried to stop the liferay war before the deploy and it still fails with the same error. The only way to get a successful re deploy is to stop and start the server. ( I can't remember if an undeploy is required before the stop start of the server)

      Note: The hibernate3.jar is available in the Web-inf/lib directory and contains org/hibernate/cache/CacheException.

      After some investigation, the root cause of this seems to be related to mixing classes from different classloaders. The portal-kernal.jar, which is loaded by WebLogic server, contains the class com.liferay.portal.kernel.cache.CacheRegistry. The CacheRegistery allows Cache objects to be registered with it. The portal-impl.jar which is loaded by a lower level class loader registers Cache Objects in the CacheRegistery.

      The glitch is that the CacheRegistry Object classloader does not have all of the dependencies required for the Cache Objects that are stored within it. So when the EHCache class tries to create a instance of the org.hibernate.cache.CacheException it is not available to the CacheRegistery classloader. Even though the org.hibernate.cache.CacheException is available to the portal-impl.jar

      I moved the portal-kernal.jar and portal-service.jar to web-inf/lib and initial deployed liferay which was successful. I am now able to perform successful re-deploys with the above noted failure.

      To actually fix, I would recommend moving the CacheRegistry out of the portal-kernal.jar and into the portal-impl.jar
      Note: in 5.2.2 it looks like the CacheRegistry is only every referenced by by classes in portal-impl.jar




            • Votes:
              0 Vote for this issue
              5 Start watching this issue


              • Created:
                Days since last comment:
                8 years, 44 weeks ago