我正在使用Liferay和Salesforce。我是Liferay的新手,我遇到了一個我花費太多時間的問題。Liferay 7 Service Builder錯誤[NoClassDefFoundError]
我有一個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>
關於開展我的門戶,我得到這個錯誤:
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)
任何想法如何解決這個問題?
你在哪裏有你的portlet war文件中的newService-api? – YuVi
爲什麼使用Comp Comp = CompLocalServiceUtil.createComp(3);'?你是否在'CompImpl'中實現了你的overriden方法? – German
那麼newService-api實際上應該從osgi而不是portlet調用,據我所知, 關於CompImpl,我其實並沒有。 –