0

我正在尝试从 portlet B 调用 XXXLocalServiceUtil 的方法,该方法已使用服务构建器在 portlet A 上创建。我在 portlet B 的 /WEB-INF/lib 中导入了完全相同的 portlet A jar,但在日志中似乎抛出了 ClassNotFoundException。有任何想法吗?

Blockquote 13:04:25,904 错误 [http-bio-8080-exec-77][render_portlet_jsp:132] null java.lang.RuntimeException: java.lang.ClassNotFoundException 不是 com.liferay.custom.action.service 的有效异常.AuditUserLocalServiceClp.addAuditUser(AuditUserLocalServiceClp.java:763) 在 com.liferay.custom.action.service.AuditUserLocalServiceUtil.addAuditUser(AuditUserLocalServiceUtil.java:287) 在 com.liferay.calendar.listeners.CalendarBookingListener.onAfterCreate(CalendarBookingListener.java:73) ) 在 com.liferay.portal.model.BaseModelListener.onAfterCreate(BaseModelListener.java:1) 在 com.liferay.portal.service.persistence 的 com.liferay.calendar.listeners.CalendarBookingListener.onAfterCreate(CalendarBookingListener.java:1)。 impl.BasePersistenceImpl.update(BasePersistenceImpl.java:337) 在 com.liferay.portal。dao.shard.advice.ShardPersistenceAdvice.invoke(ShardPersistenceAdvice.java:54) 在 com.liferay.calendar.service.impl.CalendarBookingLocalServiceImpl.addCalendarBooking(CalendarBookingLocalServiceImpl.java:174) 在 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation。在 com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62) 在 com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51) 继续(ServiceBeanMethodInvocation.java:115)在 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) 在 com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) 在 com.liferay.portal.spring .aop.ServiceBeanMethodInvocation。在 com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) 在 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) 继续(ServiceBeanMethodInvocation.java:111)在 com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) 在 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) 在 com.liferay.portal.spring .aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) BlockquoteServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) 在 com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) 在 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java: 111) 在 com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) 在 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) BlockquoteServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) 在 com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) 在 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java: 111) 在 com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) 在 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) Blockquote在 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) 处调用(ChainableMethodAdvice.java:56) 块引用在 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) 处调用(ChainableMethodAdvice.java:56) 块引用

4

3 回答 3

0

假设您的项目的项目/WAR 名称是 a-portlet 和 b-portlet:

a-portlet 的服务将在 中可用a-service.jar,它位于a-portlet/WEB-INF/lib. b-portlet/WEB-INF/liferay-plugin-package.properties您可以通过编辑和添加轻松声明 b-portlet 对 a-portlet 的依赖关系

required-deployment-contexts=a-portlet   

这将使 a-portleta-service.jar对 b-portlet 可用,并且仅在成功部署 a-portlet 时才部署 b-portlet。当重新部署 a-portlet 时,它还将重新部署 b-portlet。

或者,您可以a-service.jar在全局类路径上使用,但这意味着每次更改它时都会重新启动服务器。

于 2014-07-21T16:39:03.183 回答
0

您的 XXXLocalServiceUtil 只能在 Portlet A 中使用。要使您的服务对两个 Portlet 都可用,请在服务器级别使它们全局可用。

在 Tomcat 中,您应该将 services.jar 文件放入 /tomcat/lib/ext,并且不要忘记从 portlet 本身中删除该 JAR。更改后必须重新启动服务器。

于 2014-07-21T10:34:45.673 回答
0

要在 portlet A 和 B 之间共享 service.jar,请添加

required-deployment-contexts=a-portlet

运行b-portlet/docroot/WEB-INF/liferay-plugin-package.properties 'ant all' 它会自动将 a-portlet-service.jar 放到b-portlet/docroot/WEB-INF/lib. 还有一个细节,portlet肯定有不同的包……别问我为什么……

于 2014-07-21T21:50:19.657 回答