Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: RE: NoClassDefFoundError on GuestbookEntry folowing guestbook tutorial
Hello evry body,
I am folowwing the Guestbook tutorial : https://help.liferay.com/hc/en-us/articles/360029316371-Developer-Tutorials
I am facing a NoClassDefFoundError issue :
Caused by:
com.liferay.portal.kernel.portlet.PortletContainerException:
javax.servlet.ServletException: java.lang.NoClassDefFoundError:
com/liferay/docs/guestbook/model/GuestbookEntry
at
com.liferay.portlet.internal.PortletContainerImpl._preserveGroupIds(PortletContainerImpl.java:424)
~[portal-impl.jar:?]
at
com.liferay.portlet.internal.PortletContainerImpl.render(PortletContainerImpl.java:211)
~[portal-impl.jar:?]
at
com.liferay.portlet.SecurityPortletContainerWrapper.render(SecurityPortletContainerWrapper.java:134)
~[portal-impl.jar:?]
at
com.liferay.portlet.RestrictPortletContainerWrapper.lambda$render$0(RestrictPortletContainerWrapper.java:124)
~[portal-impl.jar:?]
at
com.liferay.portlet.RestrictPortletContainerWrapper._render(RestrictPortletContainerWrapper.java:185)
~[portal-impl.jar:?]
at
com.liferay.portlet.RestrictPortletContainerWrapper.render(RestrictPortletContainerWrapper.java:122)
~[portal-impl.jar:?]
at
com.liferay.portal.kernel.portlet.PortletContainerUtil.render(PortletContainerUtil.java:214)
~[portal-kernel.jar:?]
at
com.liferay.portal.layoutconfiguration.util.PortletRenderer._render(PortletRenderer.java:149)
~[portal-impl.jar:?]
at
com.liferay.portal.layoutconfiguration.util.PortletRenderer.render(PortletRenderer.java:65)
~[portal-impl.jar:?]
at
com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.doProcessTemplate(RuntimePageImpl.java:482)
~[portal-impl.jar:?]
at
com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.doDispatch(RuntimePageImpl.java:339)
~[portal-impl.jar:?]
at
com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.processTemplate(RuntimePageImpl.java:142)
~[portal-impl.jar:?]
at
com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.processTemplate(RuntimePageImpl.java:167)
~[portal-impl.jar:?]
at
com.liferay.portal.kernel.layoutconfiguration.util.RuntimePageUtil.processTemplate(RuntimePageUtil.java:89)
~[portal-kernel.jar:?]
at
com.liferay.layout.taglib.servlet.taglib.RenderLayoutStructureTag._renderDropZoneLayoutStructureItem(RenderLayoutStructureTag.java:848)
~[?:?]
at
com.liferay.layout.taglib.servlet.taglib.RenderLayoutStructureTag._renderLayoutStructure(RenderLayoutStructureTag.java:1065)
~[?:?]
at
com.liferay.layout.taglib.servlet.taglib.RenderLayoutStructureTag._renderLayoutStructure(RenderLayoutStructureTag.java:1138)
~[?:?]
at
com.liferay.layout.taglib.servlet.taglib.RenderLayoutStructureTag.processStartTag(RenderLayoutStructureTag.java:169)
~[?:?]
at
com.liferay.taglib.util.IncludeTag.doStartTag(IncludeTag.java:116)
~[util-taglib.jar:?]
at
org.apache.jsp.layout.view.portlet_jsp._jspService(portlet_jsp:214)
~[?:?]
... 165 more
Here is my environnement conficuration (I submitted my project on github : https://github.com/stmEvBy/guestbook-tuto.git):
- eclipse 2022-03
- liferay eclipse plugin : liferay-ide-updatesite-3.9.6-ga7-202203281408.zip
- eclipse.ini :
-vm
C:/myfolder/Amazon
Corretto/jdk11.0.14_10/bin
- gradle.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
- liferay bundle
server:
liferay-ce-portal-7.4.3.30-ga30
-
bnd.bnd guestbook-web
Bundle-Name: guestbook-web
Bundle-SymbolicName: com.liferay.docs.guestbook.portlet
Bundle-Version: 1.0.0
Export-Package:
com.liferay.docs.guestbook.portlet.constants
-
bnd.bnd guestbook-service
Bundle-Name:
guestbook-service
Bundle-SymbolicName:
com.liferay.docs.guestbook.service
Bundle-Version:
1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true
-dsannotations-options: inherit
- bnd.bnd guestbook-api
Bundle-Name:
guestbook-api
Bundle-SymbolicName:
com.liferay.docs.guestbook.api
Bundle-Version: 1.0.0
Export-Package:\
com.liferay.docs.guestbook.exception,\
com.liferay.docs.guestbook.model,\
com.liferay.docs.guestbook.service,\
com.liferay.docs.guestbook.service.persistence
-check:
EXPORTS
-includeresource:
META-INF/service.xml=../guestbook-service/service.xml
- service.xml
<?xml version="1.0"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service
Builder 7.4.0//EN"
"http://www.liferay.com/dtd/liferay-service-builder_7_4_0.dtd">
<service-builder dependency-injector="ds"
package-path="com.liferay.docs.guestbook"
mvcc-enabled="true">
<author>liferay</author>
<namespace>GB</namespace>
<entity
name="Guestbook" local-service="true"
uuid="true"
remote-service="true">
<!-- Guestbook fields -->
<column name="guestbookId"
primary="true" type="long" />
<column name="name" type="String" />
<!-- Group instance -->
<column name="groupId" type="long"
/>
<column name="companyId"
type="long" />
<!-- Audit fields -->
<column name="userId" type="long"
/>
<column name="userName"
type="String" />
<column
name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />
<!-- Status fields -->
<column name="status" type="int"
/>
<column name="statusByUserId"
type="long" />
<column
name="statusByUserName" type="String" />
<column name="statusDate"
type="Date" />
<finder name="GroupId"
return-type="Collection">
<finder-column name="groupId" />
</finder>
</entity>
<entity name="GuestbookEntry"
local-service="true"
remote-service="true" uuid="true">
<!-- Guestbook Entry fields -->
<!-- [Implementing Service Methods] refresh service - refresh api
- gradle refresh service - gradle refresh api -->
<column name="entryId" primary="true"
type="long" />
<column
name="name" type="String" />
<column name="email" type="String" />
<column name="message"
type="String" />
<column
name="guestbookId" type="long" />
<!-- Group instance -->
<column name="groupId" type="long"
/>
<column name="companyId"
type="long" />
<!-- Audit fields -->
<column name="userId" type="long"
/>
<column name="userName"
type="String" />
<column
name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />
<!-- Status fields -->
<column name="status" type="int"
/>
<column name="statusByUserId"
type="long" />
<column
name="statusByUserName" type="String" />
<column name="statusDate"
type="Date" />
<order>
<order-column
name="createDate" order-by="desc" />
</order>
<finder name="G_G"
return-type="Collection">
<finder-column name="groupId" />
<finder-column name="guestbookId" />
</finder>
</entity>
<exceptions>
<exception>GuestbookEntryEmail</exception>
<exception>GuestbookEntryMessage</exception>
<exception>GuestbookEntryName</exception>
<exception>GuestbookName</exception>
</exceptions>
</service-builder>
- edit_entry.jsp
<%@ include file="../init.jsp" %>
<%
long entryId = com.liferay.portal.kernel.util.ParamUtil.getLong(renderRequest, "entryId");
com.liferay.docs.guestbook.model.GuestbookEntry entry =
null;
if (entryId > 0) {
entry =
com.liferay.docs.guestbook.service.GuestbookEntryLocalServiceUtil.getGuestbookEntry(entryId);
}
long guestbookId = com.liferay.portal.kernel.util.ParamUtil.getLong(renderRequest, "guestbookId");
%>
<portlet:renderURL var="viewURL">
<portlet:param name="mvcPath"
value="/guestbook/view.jsp"></portlet:param>
</portlet:renderURL>
<portlet:actionURL name="addEntry" var="addEntryURL" />
<aui:form action="<%= addEntryURL %>" name="<portlet:namespace />fm">
<aui:model-context bean="<%= entry %>" model="<%= com.liferay.docs.guestbook.model.GuestbookEntry.class %>" />
<aui:fieldset>
<aui:input name="name" />
<aui:input name="email" />
<aui:input name="message" />
<aui:input name="entryId" type="hidden"
/>
<aui:input name="guestbookId"
type="hidden" value='<%= entry == null ? guestbookId :
entry.getGuestbookId() %>'/>
</aui:fieldset>
<aui:button-row>
<aui:button
type="submit"></aui:button>
<aui:button type="cancel" onClick="<%=
viewURL.toString() %>"></aui:button>
</aui:button-row>
</aui:form>
Does the problem come form the service.xml or is it a configuration problem?
At a glance, try changing this line in the JSP
<aui:model-context bean="<%= entry %>" model="<%= com.liferay.docs.guestbook.model.GuestbookEntry.class %>" />
to
<aui:model-context bean="<%= entry %>" model="<%= GuestbookEntry.class %>" />
But in general with this tutorial you should also tell us which step you failed at--helps with pinpointing when the problem was introduced.
My guess is that ou were at this step.
Hello Russell,
Thank's for your answer. You are rigth, this is step "Forms and Action URLs" step.
The first time I edited edit_entry.jsp, I tried this jsp code sample :
<aui:model-context bean="<%= entry %>" model="<%= GuestbookEntry.class %>" />
Unfortunatly this cause compile error:
Unable to dispatch request: PWC6033: Error in Javac compilation for JSP__PWC6197: An error occurred at line: 25 in the jsp file: /guestbook/edit_entry.jsp_PWC6199: Generated servlet error:_cannot find symbol_ symbol: class GuestbookEntry_ location: class org.apache.jsp.guestbook.edit_005fentry_jsp__ [Sanitized]
Hi Stephane, have you imported the class in your init.jsp?
<%@ page import="com.liferay.docs.guestbook.model.GuestbookEntry" %>
It's OK. It's working. Thank you.
Powered by Liferay™