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
-
Fix Version/s: 6.1.X EE, 6.2.0 CE M5
-
Component/s: Tools, Tools > Service Builder
-
Labels:
-
Environment:HideLinux 2.6.32-5-686 #1 SMP Tue Jun 1 04:59:47 UTC 2010 i686 GNU/Linux
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Liferay v6.0 (Tomcat 6.0.26) SVN trunk rev.57489
Liferay Portal Community Edition 6.0.3 CE (Bunyan / Build 6003 / June 8, 2010)
ShowLinux 2.6.32-5-686 #1 SMP Tue Jun 1 04:59:47 UTC 2010 i686 GNU/Linux Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Liferay v6.0 (Tomcat 6.0.26) SVN trunk rev.57489 Liferay Portal Community Edition 6.0.3 CE (Bunyan / Build 6003 / June 8, 2010)
-
Branch Version/s:6.1.x
-
Backported to Branch:Committed
-
Epic/Theme:
-
Story Points:2
-
Fix Priority:3
-
Liferay Contributor's Agreement:Accept
-
Similar Issues:
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".

As a workaround it's possible to expand the build-service task mentioned in the recipe to include a replace like:
<replace
{basedir}dir="$
/docroot/WEB-INF/src/<your service package>/service/persistence"
includes="*PersistenceImpl.java"
summary="yes">
<replacefilter>
<replacetoken>import com.liferay.portal.kernel.log.LogFactoryUtil;</replacetoken>
<replacevalue>import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.portlet.PortletClassLoaderUtil;</replacevalue>
</replacefilter>
<replacefilter
token="InstanceFactory.newInstance("
value="InstanceFactory.newInstance(PortletClassLoaderUtil.getClassLoader (),"/>
</replace>