guestbook-web portal can’t refer to source codes in guestbook-api/serviceguestbook-web portal can’t refer to source codes in guestbook-api/servicehttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1172610972024-03-29T07:51:52Z2024-03-29T07:51:52ZRE: guestbook-web portal can’t refer to source codes in guestbook-api/serviOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1172675392019-09-23T19:54:49Z2019-09-23T19:54:49Z<div class="quote-title">David H Nebinger:</div><blockquote><br />Actually Olaf if you check the doco you'll see that, in fact and unfortunately, we do suggest that both be added as a dependency. I also see the use of GuestbookEntryLocalServiceUtil which is also an antipattern that I wish the documentation was not suggesting that anyone use.<br /></blockquote>Ouch. I've commented on the documentation page, hope that it'll be fixed & updated soon.Olaf Kock2019-09-23T19:54:49ZRE: guestbook-web portal can’t refer to source codes in guestbook-api/serviDavid H Nebingerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1172671522019-09-23T18:50:42Z2019-09-23T18:50:42ZActually Olaf if you check the doco you'll see that, in fact and unfortunately, we do suggest that both be added as a dependency. I also see the use of GuestbookEntryLocalServiceUtil which is also an antipattern that I wish the documentation was not suggesting that anyone use.<br /><br />Alan, adding a dependency in your build.gradle file is (mostly) just specifying a dependency that is necessary for the java code compile. It does not include the dependency in the deployment artifact itself.<br /><br />The error is saying that it cannot find the class GuestbookEntryLocalServiceUtil which itself means in the runtime the class is not available. This normally means something like you've deployed your -web module but did not actually deploy the guestbook api and/or guestbook service modules. All three of these modules would normally be deployed to the container and also normally they must all be in the active state and the component services they implement would also be active.David H Nebinger2019-09-23T18:50:42ZRE: guestbook-web portal can’t refer to source codes in guestbook-api/serviOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1172624932019-09-23T14:46:58Z2019-09-23T14:46:58ZYour -web project should only have a dependency on the -api module, never on the -service. That's the proper decoupling<br />I'd assume that the docs don't introduce this dependency - otherwise please let me (or us) know where they do, so that this mistake can be corrected.<br />If you have code that shouldn't go into the -api project, simply create a new project and depend on it - not on the service.Olaf Kock2019-09-23T14:46:58Zguestbook-web portal can’t refer to source codes in guestbook-api/serviceAlan Chanhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1172610962019-09-23T14:40:44Z2019-09-23T14:40:44ZHi everyone,<br />I tried to follow the steps from the beginning of “Developing a Web Application” ( <a href="https://portal.liferay.dev/docs/7-2/tutorials/-/knowledge_base/t/developing-a-web-application">https://portal.liferay.dev/docs/7-2/tutorials/-/knowledge_base/t/developing-a-web-application</a> ) and got stuck in “Building the Web Front-End Step 4 of 11” of “Developing a Web Application” (ver. 7.2).<br />Here are my current source codes:<a href="https://github.com/alanmih/liferay_guestbook-workspace">https://github.com/alanmih/liferay_guestbook-workspace</a><br />The issue I was encountering is that it seems whenever my guestbook-web is trying to refer to the source codes in either guestbook-api or guestbook-service in the runtime after its deployment, it will fail and get the below error. <br />Also, in the jsp files such as init.jsp (META-INF/resources/init.jsp in guestbook-web), referring to any classes in guestbook-api or guestbook-service will fail the app too. <br />The point which confused me most is that I already added the module dependencies (for guestbook-api and guestbook-service) to build.grandle as guided in <a href="https://portal.liferay.dev/docs/7-2/tutorials/-/knowledge_base/t/integrating-the-back-end">https://portal.liferay.dev/docs/7-2/tutorials/-/knowledge_base/t/integrating-the-back-end</a> and it shows no error in my IDE and compilation. However, after guestbook-web is compiled and deployed to the Liferay-portal (ver. 7.2) it seems that “it can’t find” any classes in guestbook-api or guestbook-service, even though I already defined the module dependencies in guestbook-web’s build.grandle.<br /><br />I tried other possible solutions such as adding modules/guestbook/guestbook-api/build/tmp/jar/com.liferay.docs.guestbook.api-1.0.0.jar and modules/guestbook/guestbook-service/build/tmp/jar/com.liferay.docs.guestbook.service-1.0.0.jar to modules/guestbook/guestbook-web/src/main/resources/META-INF/resources and refer them directly from guestbook-web’s build.grandle but the result is still the same.<br />It’s highly appreciated if anyone could help and let me know what can be the possible causes or solutions…<br />2019-09-23 13:54:15.696 ERROR [http-nio-8080-exec-9][PortletServlet:119] javax.portlet.PortletException: java.lang.NoClassDefFoundError: com/liferay/docs/guestbook/service/GuestbookEntryLocalServiceUtiljavax.portlet.PortletException: java.lang.NoClassDefFoundError: com/liferay/docs/guestbook/service/GuestbookEntryLocalServiceUtilat com.liferay.portal.kernel.portlet.LiferayPortlet.callActionMethod(LiferayPortlet.java:207)at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.callActionMethod(MVCPortlet.java:401)at com.liferay.portal.kernel.portlet.LiferayPortlet.processAction(LiferayPortlet.java:97)at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.processAction(MVCPortlet.java:246)at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:77)at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:50)at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:115)at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:62)at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:120)at org.eclipse.equinox.http.servlet.internal.servlet.RequestDispatcherAdaptor.include(RequestDispatcherAdaptor.java:48)at com.liferay.portlet.internal.InvokerPortletImpl.invoke(InvokerPortletImpl.java:573)at com.liferay.portlet.internal.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:620)at com.liferay.portlet.internal.InvokerPortletImpl.processAction(InvokerPortletImpl.java:304)at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.processAction(MonitoringInvokerPortlet.java:216)at com.liferay.portlet.internal.PortletContainerImpl._processAction(PortletContainerImpl.java:524)at com.liferay.portlet.internal.PortletContainerImpl.lambda$processAction$0(PortletContainerImpl.java:151)at com.liferay.portlet.internal.PortletContainerImpl._preserveGroupIds(PortletContainerImpl.java:427)at com.liferay.portlet.internal.PortletContainerImpl.processAction(PortletContainerImpl.java:144)at com.liferay.portlet.SecurityPortletContainerWrapper.processAction(SecurityPortletContainerWrapper.java:96)at com.liferay.portlet.RestrictPortletContainerWrapper.processAction(RestrictPortletContainerWrapper.java:79)at com.liferay.portal.kernel.portlet.PortletContainerUtil.processAction(PortletContainerUtil.java:118)at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:352)at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:174)at com.liferay.portal.struts.PortalRequestProcessor._process(PortalRequestProcessor.java:415)at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:155)at com.liferay.portal.internal.servlet.MainServlet.doPost(MainServlet.java:213)at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)at com.liferay.portal.internal.servlet.MainServlet.service(MainServlet.java:639)at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:124)at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)at com.liferay.portal.servlet.filters.uploadservletrequest.UploadServletRequestFilter.processFilter(UploadServletRequestFilter.java:114)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.servlet.filters.password.modified.PasswordModifiedFilter.processFilter(PasswordModifiedFilter.java:62)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)at com.liferay.portal.servlet.filters.secure.BaseAuthFilter.processFilter(BaseAuthFilter.java:360)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)at com.liferay.portal.monitoring.internal.servlet.filter.MonitoringFilter.processFilter(MonitoringFilter.java:181)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:106)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)at com.liferay.friendly.url.internal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:398)at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)at com.liferay.portal.servlet.ServletAdapter.service(ServletAdapter.java:99)at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:124)at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)at com.liferay.portal.servlet.filters.uploadservletrequest.UploadServletRequestFilter.processFilter(UploadServletRequestFilter.java:114)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:370)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.servlet.filters.password.modified.PasswordModifiedFilter.processFilter(PasswordModifiedFilter.java:62)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)at com.liferay.portal.servlet.filters.secure.BaseAuthFilter.processFilter(BaseAuthFilter.java:360)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:266)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:266)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)at com.liferay.portal.monitoring.internal.servlet.filter.MonitoringFilter.processFilter(MonitoringFilter.java:181)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:65)at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:175)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:175)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:106)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:748)Caused by: java.lang.NoClassDefFoundError: com/liferay/docs/guestbook/service/GuestbookEntryLocalServiceUtilat com.liferay.docs.guestbook.portlet.GuestbookPortlet.addEntry(GuestbookPortlet.java:95)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 com.liferay.portal.kernel.portlet.LiferayPortlet.callActionMethod(LiferayPortlet.java:189)... 148 moreCaused by: java.lang.ClassNotFoundException: com.liferay.docs.guestbook.service.GuestbookEntryLocalServiceUtil cannot be found by com.liferay.docs.guestbook.portlet_1.0.0at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:508)at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:419)at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:411)at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)at java.lang.ClassLoader.loadClass(ClassLoader.java:357)... 154 more<br /><br />P.S. I found that I can’t use the annotation (even I already defined the dependency: compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations" in build.grandle ) such as @Reference also, otherwise it would fail the deployment