0

I'm trying to call , from portlet B, a method of XXXLocalServiceUtil which has been created on portlet A with service builder. I have imported the exact same jar of portlet A in /WEB-INF/lib of portlet B but as it seems in the log a ClassNotFoundException is thrown. Any ideas?

Blockquote 13:04:25,904 ERROR [http-bio-8080-exec-77][render_portlet_jsp:132] null java.lang.RuntimeException: java.lang.ClassNotFoundException is not a valid exception at com.liferay.custom.action.service.AuditUserLocalServiceClp.addAuditUser(AuditUserLocalServiceClp.java:763) at com.liferay.custom.action.service.AuditUserLocalServiceUtil.addAuditUser(AuditUserLocalServiceUtil.java:287) at com.liferay.calendar.listeners.CalendarBookingListener.onAfterCreate(CalendarBookingListener.java:73) at com.liferay.calendar.listeners.CalendarBookingListener.onAfterCreate(CalendarBookingListener.java:1) at com.liferay.portal.model.BaseModelListener.onAfterCreate(BaseModelListener.java:1) at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.update(BasePersistenceImpl.java:337) at com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice.invoke(ShardPersistenceAdvice.java:54) at com.liferay.calendar.service.impl.CalendarBookingLocalServiceImpl.addCalendarBooking(CalendarBookingLocalServiceImpl.java:174) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115) at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62) at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) Blockquote

jkonst
  • 433
  • 6
  • 20

3 Answers3

0

Your XXXLocalServiceUtil will only available withing the Portlet A. To make your services available to both portlets, make them available globally on the server level.

In Tomcat you should put the services.jar file to /tomcat/lib/ext, and don't forget to remove that JAR from the portlet itself. Server must be restarted after this change.

Artem Khojoyan
  • 857
  • 1
  • 6
  • 11
  • Well I tried what you suggested and it worked only the first time. After rebuilding and redeploying portlet B, which by the way is an extension of social calendar, the same exception is thrown and this keeps even after restarting tomcat. – jkonst Jul 21 '14 at 12:03
  • You said that you've included the JAR in the portletB. Make sure the JAR is removed from both portlets and then redeploy again. Also would be good to make a clean deployment - remove all the war applications, cleanup the /temp/ and /work/ folders and then start the portal again and deploy your both portlets. – Artem Khojoyan Jul 21 '14 at 15:36
  • Yes I had to remove jar also from original portlet A as well as cleaning temp and work folders. – jkonst Jul 22 '14 at 07:53
0

Assuming that the project / WAR names for your projects are a-portlet and b-portlet:

The services for a-portlet will be available in a-service.jar, which lives in a-portlet/WEB-INF/lib. You can easily declare a dependency of b-portlet on a-portlet by editing b-portlet/WEB-INF/liferay-plugin-package.properties and add

required-deployment-contexts=a-portlet   

This will make a-portlet's a-service.jar available to b-portlet and only deploy b-portlet if a-portlet has successfully been deployed. It will also redeploy b-portlet when a-portlet is redeployed.

Alternatively, you can make a-service.jar available on the global classpath, but this implies a server restart every time you change it.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
0

To share service.jar between portlets A and B add

required-deployment-contexts=a-portlet

to b-portlet/docroot/WEB-INF/liferay-plugin-package.properties and run 'ant all' it will automatically put a-portlet-service.jar to b-portlet/docroot/WEB-INF/lib. There is also one detail, portlets must have different packages... dont ask me why...

Prime
  • 1,165
  • 6
  • 6