Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Liferay 如何从portlet调用ServiceBuilder构建的服务_Liferay - Fatal编程技术网

Liferay 如何从portlet调用ServiceBuilder构建的服务

Liferay 如何从portlet调用ServiceBuilder构建的服务,liferay,Liferay,问题是我创建了一个Liferay portlet来调用它 由Liferay service Builder在之前创建的服务(名称为LocaleContentLocalServiceUtil) 该服务在Liferay中工作,但当我调用该服务时 从portlet中,我得到了NullerpointerException 我激活了调试模式,发现LocaleContentLocalServiceUtil中的PortalBeanLocatorUtil.locate(LocaleContentLocalSer

问题是我创建了一个Liferay portlet来调用它

由Liferay service Builder在之前创建的服务(名称为LocaleContentLocalServiceUtil)

该服务在Liferay中工作,但当我调用该服务时

从portlet中,我得到了NullerpointerException

我激活了调试模式,发现LocaleContentLocalServiceUtil中的
PortalBeanLocatorUtil.locate(LocaleContentLocalService.class.getName())
的返回值为null


是否有人知道如何解决此问题,或者可以给我一些指导,请帮助我。

在您的portlet的liferay-plugin-package.properties中添加以下属性。确保ServiceJAR是已部署PortletWebApps的类路径

required-deployment-contexts=your-service-portlet

如果此属性不存在,请尝试将service-api.jar复制到tomcat/lib/ext中,并从服务和所有其他portlet中删除。

在portlet的liferay-plugin-package.properties中添加以下属性。确保ServiceJAR是已部署PortletWebApps的类路径

required-deployment-contexts=your-service-portlet

如果此属性不存在,请尝试将service-api.jar复制到tomcat/lib/ext中,并从服务和所有其他portlet中删除。

哪个liferay版本?您所说的服务在liferay中工作是什么意思?@Rajesh my liferay版本是6.1.0CE@MiroslavLigas我将service Builder创建的类(持久性、服务、util…)放入liferay,调用类DLFolderWrapper中的服务(LocaleContentLocalServiceUtil),然后对其进行测试,我想要的新功能可以正常工作。但是我在创建的portlet中调用服务(LocaleCOntentLocalServiceUtil),异常被抛出。哪个liferay版本?服务在liferay中工作是什么意思?@Rajesh我的liferay版本是6.1.0CE@MiroslavLigas我将服务生成器创建的类(持久性、服务、util…)放入liferay,并调用服务(LocaleContentLocalServiceUtil)在类DLFolderWrapper中,然后我测试了它,我想要的新功能确实有效在我创建的portlet中,异常被抛出。我尝试设置属性,现在我得到了错误消息msg
java.lang.ClassCastException:com.sun.proxy。$Proxy339不能强制转换为com.liferay.eip.portal.service.LocaleContentLocalService
,我添加这些代码以检查PortalBeanLocatorUtil.locate
Objec返回值的值t klassObj=PortalBeanLocatorUtil.locate(LocaleContentLocalService.class.getName());System.out.println(klassObj.getClass().getName())当LocaleContentLocalService类从门户或我创建的portlet调用时,我得到了com.sun.proxy.$Proxy339。我不明白为什么从门户调用可以成功地强制转换,但从我创建的portlet调用失败?这是因为在多个位置复制了服务api jar。尝试将服务api jar放入tomc中在您的portlet和服务portlet的/lib/ext和webinf/lib中删除,最终我解决了这个问题。正如您所说,原因是我在多个地方有我的服务api。我删除了所有的服务api,但将其中一个保留在tomcat/lib/ext中,现在它在portlet和门户端都可以正常工作。非常感谢^^我尝试设置属性,现在我得到了它s error msg
java.lang.ClassCastException:com.sun.proxy.$Proxy339不能强制转换为com.liferay.eip.portal.service.LocaleContentLocalService
,我添加这些代码是为了检查PortalBeanLocatorUtil.locate
对象klassbj=PortalBeanLocatorUtil.locate(LocaleContentLocalService.class.getName())返回值的值;System.out.println(klassObj.getClass().getName())当LocaleContentLocalService类从门户或我创建的portlet调用时,我得到了com.sun.proxy.$Proxy339。我不明白为什么从门户调用可以成功地强制转换,但从我创建的portlet调用失败?这是因为在多个位置复制了服务api jar。尝试将服务api jar放入tomc中您的portlet和服务portlet的/lib/ext和webinf/lib中的delete最后我解决了这个问题。正如您所说,原因是我在多个地方有我的服务api。我删除了所有的服务api,但将其保留在tomcat/lib/ext中,现在它在portlet和门户端都可以正常工作。非常感谢您^^