我在Liferay和Salesforce工作。我是Liferay的新手,我遇到了一个花了太多时间的问题。
我有一个portlet,我决定创建一个Service Builder(名为" newService")。这是我的service.xml:
<service-builder package-path="com.fr.liferay">
<namespace>SSB</namespace>
<entity local-service="true" name="Comp" remote-service="false" uuid="true">
<!--<entity name="Foo" table="foo" uuid="true" local-service="true" remote-service="false" data-source="sampleDataSource" session-factory="sampleSessionFactory" tx-manager="sampleTransactionManager">-->
<!-- PK fields -->
<column name="compId" primary="true" type="long" />
<!-- Group instance -->
<column name="groupId" type="long" />
<!-- Audit fields -->
<column name="companyId" type="long" />
<column name="userId" type="long" />
<column name="userName" type="String" />
<column name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />
<!-- Other fields -->
<column name="compName" type="String" />
<column name="compDesc" type="String" />
<column name="compPath" type="String" />
<!-- Order -->
<!-- References -->
</entity>
</service-builder>
现在,我运行maven命令:mvn service-builder:build
并生成newService-api
工件。
我在我的portlet中调用服务,如下所示:
Comp comp = CompLocalServiceUtil.createComp(3);
comp.persist();
我在portlet的pom.xml中添加了newservice-api
依赖项:
<dependency>
<groupId>com.fr.liferay.liferay7-
architecture.portail7.services.newService</groupId>
<artifactId>newService-api</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
在启动我的portlet时,我收到此错误:
Caused by: java.lang.NoClassDefFoundError: com/fr/liferay/service/CompLocalServiceUtil
at com.fr.liferay.controllers.TestController.actionTwoMethod(TestController.java:151)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:180)
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:367)
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:354)
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleAction(AnnotationMethodHandlerAdapter.java:285)
at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:666)
... 181 more
12:55:57,243 ERROR [http-nio-8080-exec-5][render_portlet_jsp:131] null
java.lang.NoClassDefFoundError: com/fr/liferay/service/CompLocalServiceUtil
at com.fr.liferay.controllers.TestController.actionTwoMethod(TestController.java:151)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:71)
at com.liferay.portlet.CheckboxParametersPortletFilter.doFilter(CheckboxParametersPortletFilter.java:57)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:68)
at com.liferay.portlet.CheckboxParametersPortletFilter.doFilter(CheckboxParametersPortletFilter.java:57)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:68)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:105)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletExceptionAdapter.service(ServletExceptionAdapter.java:68)
at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)
at org.eclipse.equinox.http.servlet.internal.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:50)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:115)
at com.liferay.portal.osgi.web.wab.extender.internal.adapter.FilterExceptionAdapter.doFilter(FilterExceptionAdapter.java:46)
at org.eclipse.equinox.http.servlet.internal.registration.FilterRegistration.doFilter(FilterRegistration.java:121)
at org.eclipse.equinox.http.servlet.internal.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:45)
at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:70)
at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:117)
at org.eclipse.equinox.http.servlet.internal.servlet.RequestDispatcherAdaptor.include(RequestDispatcherAdaptor.java:48)
知道如何解决这个问题吗?
答案 0 :(得分:0)
我想把它写成评论,但它太长了所以我只能把它作为答案发布,对不起。
您可以创建您的活动,所有持久化/模型/等等都由ServiceBuilder完成。在Liferay 7中,它由两个模块表示:api和service。在maven&#34; build&#34;和servicebuilder&#34; build-service&#34;您可以使用默认的crud方法,例如CompLocalServiceUtil.deleteComp()
和其他方法。并且您已经写过使用CompLocalServiceUtil.createComp(3)
,这意味着您已经在CompLocalServiceImpl.java
文件中覆盖了该默认方法。这是真的吗?如果不是 - 这就是您出错的原因。
如果您想添加自己的业务逻辑 - 您应该修改(并再次构建服务)CompLocalServiceImpl
,如果您想添加自己的模型 - 您应该修改CompImpl.java
可能我只是误解了你。