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

Custom Model Listener: value.object.listener on plugin portlet sdk project throw java.langClassNotFoundException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.3 GA, 6.0.6 GA, 6.0.12 EE, 6.1.0 CE RC1, 6.1.1 CE GA2, 6.1.20 EE GA2
    • Labels:
    • Environment:
    • Branch Version/s:
      6.1.x, 6.0.x
    • Backported to Branch:
      Committed
    • Epic/Theme:
    • Story Points:
      2
    • Fix Priority:
      3

      Description

      When follow the recipe desribed in http://www.liferay.com/community/forums/-/message_boards/message/3229889 (How to Create Model Listener Class in Plugin?) I get an error message like this:

      Loading file:/share/dev/mesalc-web/sdk/portlets/mesalc-data/docroot/WEB-INF/classes/service.properties
      15:53:26,043 ERROR [InstitutionPersistenceImpl:1420]
      java.lang.ClassNotFoundException: org.mesalc.hook.listeners.InstitutionListener
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
      at com.liferay.portal.kernel.util.InstanceFactory.newInstance(InstanceFactory.java:37)
      at com.liferay.portal.kernel.util.InstanceFactory.newInstance(InstanceFactory.java:25)
      at org.mesalc.service.persistence.InstitutionPersistenceImpl.afterPropertiesSet(InstitutionPersistenceImpl.java:1413)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      Looking at the code in XXXPersistenceImpl.afterPropertiesSet method, I could see that the invocation to create the new listerner instance:

      ...InstanceFactory.newInstance(listenerClassName));

      was made whitout specifying a ClassLoader. Testing to change this line to:

      ...InstanceFactory.newInstance(PortletClassLoaderUtil.getClassLoader (), listenerClassName));

      solve the problem, but as this class is autogenerated, I lose the changes every time I run "ant build-service".

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                6 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 38 weeks ago