Note that there are some explanatory texts on larger screens.

plurals
  1. PONoSuchMethodException in liferay portlet while adding data
    primarykey
    data
    text
    <p>I am using liferay and i have created my own portlet which have just add functionality.but some how i am having error in adding books </p> <p>this is my view.jsp</p> <pre><code>&lt;%@ include file="/init.jsp"%&gt; &lt;% Restaurant resto = (Restaurant) request.getAttribute("Restaurant"); if (resto == null) { resto = new RestaurantImpl(); resto.setTable_Count(1); } %&gt; &lt;liferay-portlet:actionURL name="addreRestaurant" var="addreRestaurantURL"&gt;&lt;/liferay-portlet:actionURL&gt; &lt;aui:form action="&lt;%=addreRestaurantURL.toString() %&gt;" method="post" name="fm"&gt; &lt;aui:fieldset&gt; &lt;%-- &lt;liferay-ui:error key="title-required" message="title-required" /&gt; --%&gt; &lt;p&gt; &lt;aui:input name="Name" label="Name" type="text" value="&lt;%=resto.getName()%&gt;"&gt;&lt;/aui:input&gt; &lt;/p&gt; &lt;%-- &lt;liferay-ui:error key="author-required" message="author-required" /&gt; --%&gt; &lt;p&gt; &lt;aui:input name="Location" label="Location" type="text" value="&lt;%=resto.getLocation() %&gt;"&gt;&lt;/aui:input&gt; &lt;/p&gt; &lt;%-- &lt;liferay-ui:error key="pages-required" message="pages-required" /&gt; &lt;liferay-ui:error key="pages-cannot-be-zero" message="pages-cannot-be-zero" /&gt; --%&gt; &lt;p&gt; &lt;aui:input name="table_count" label="Table_count" type="text" value="&lt;%=String.valueOf(resto.getTable_Count()) %&gt;"&gt;&lt;/aui:input&gt; &lt;/p&gt; &lt;p&gt; &lt;aui:input name="room_count" label="Room_count" type="text" value="&lt;%=String.valueOf(resto.getRoom_Count()) %&gt;"&gt;&lt;/aui:input&gt; &lt;/p&gt; &lt;p&gt; &lt;aui:input name="reseller_ID" label="Reseller_ID" type="text" value="&lt;%=String.valueOf(resto.getReseller_ID()) %&gt;"&gt;&lt;/aui:input&gt; &lt;/p&gt; &lt;p&gt; &lt;aui:button class="aui-button-input" type="submit" value="Submit" /&gt; &lt;aui:button class="aui-button-input" type="reset" value="Reset" /&gt; &lt;/p&gt; &lt;/aui:fieldset&gt; &lt;/aui:form&gt; &lt;liferay-ui:search-container emptyResultsMessage="no-restaurant" delta="5"&gt; &lt;/liferay-ui:search-container&gt; </code></pre> <p>And following is my service implementation class </p> <pre><code>/** * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.test.service.impl; import java.util.Collections; import java.util.List; import com.test.model.Restaurant; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; import com.test.service.base.RestaurantServiceBaseImpl; /** * The implementation of the restaurant remote service. * * &lt;p&gt; * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link com.test.service.RestaurantService} interface. * * &lt;p&gt; * This is a remote service. Methods of this service are expected to have security checks based on the propagated JAAS credentials because this service can be accessed remotely. * &lt;/p&gt; * * @author bhavik.kama * @see com.test.service.base.RestaurantServiceBaseImpl * @see com.test.service.RestaurantServiceUtil */ public class RestaurantServiceImpl extends RestaurantServiceBaseImpl { public Restaurant addreRestaurant(Restaurant restoParam) { Restaurant restoVar; try { restoVar = restaurantPersistence.create((int) counterLocalService .increment(Restaurant.class.toString())); } catch (SystemException e) { e.printStackTrace(); return restoVar = null; } try { resourceLocalService.addResources(restoParam.getCompanyId(), restoParam.getGroupId(), restoParam.getUserId(), Restaurant.class.getName(), restoParam.getPrimaryKey(),false, true, true); } catch (PortalException e) { e.printStackTrace(); return restoVar = null; } catch (SystemException e) { e.printStackTrace(); return restoVar = null; } restoVar.setLocation(restoParam.getLocation()); restoVar.setCompanyId(restoParam.getCompanyId()); restoVar.setResto_ID(restoParam.getResto_ID()); restoVar.setUserId(restoParam.getUserId()); restoVar.setGroupId(restoParam.getGroupId()); restoVar.setName(restoParam.getName()); restoVar.setRoom_Count(restoParam.getRoom_Count()); restoVar.setTable_Count(restoParam.getRoom_Count()); restoVar.setUserId(restoParam.getUserId()); try { return restaurantPersistence.update(restoVar, false); } catch (SystemException e) { e.printStackTrace(); return restoVar = null; } } public List&lt;Restaurant&gt; getAllerRestaurants() { try { return restaurantPersistence.findAll(); } catch (SystemException e) { e.printStackTrace(); return Collections.emptyList(); } } public List&lt;Restaurant&gt; getAllreRestaurants(long groupId, String title) { try { return restaurantPersistence.findByGroupId(groupId); } catch (SystemException e) { e.printStackTrace(); return Collections.emptyList(); } } } </code></pre> <p>And following error i am facing its hwoing that its cant find method of addreRestaurant but i have that method.so where am doing mistake?</p> <p>Error is as follows:</p> <pre><code>SEVERE: Servlet.service() for servlet TabsTest Servlet threw exception java.lang.NoSuchMethodException: com.liferay.util.bridges.mvc.MVCPortlet.addreRestaurant(javax.portlet.ActionRequest, javax.portlet.ActionResponse) at java.lang.Class.getMethod(Class.java:1605)..... </code></pre> <p>As follows is my Portlet Class Method to addRestaurant..</p> <pre><code>package com.test.portlet; import java.util.ArrayList; import java.util.List; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.test.model.Restaurant; import com.test.service.RestaurantServiceUtil; import com.test.util.RestaurantActionUtil; import com.test.util.RestaurantValidator; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.servlet.SessionErrors; import com.liferay.portal.kernel.servlet.SessionMessages; import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.theme.ThemeDisplay; import com.liferay.util.bridges.mvc.MVCPortlet; /** * Portlet implementation class BooksPortlet */ public class RestaurantPortlet extends MVCPortlet { private static Log log = LogFactory.getLog(RestaurantPortlet.class); private static String errorJSP="/jsps/error.jsp" ; public void addRestaurant(ActionRequest request, ActionResponse response) { log.info("Inside addRegistration"); List&lt;String&gt; errors=new ArrayList&lt;String&gt;(); Restaurant resto=RestaurantActionUtil.getRestaurantFromRequest(request); boolean bookValid=RestaurantValidator.validateBook(resto, errors); if(bookValid) { log.info(resto); Restaurant test=RestaurantServiceUtil.addreRestaurant(resto); if(test==null) { log.error("REsto was Found Null"); //response.setRenderParameter("jspPage", errorJSP); return ; } SessionMessages.add(request,"book-added"); return ; } else { for (String error : errors) { SessionErrors.add(request, error); } SessionErrors.add(request, "error-while-adding"); request.setAttribute("Restaurant",resto); return ; } } /* public void deleteBooks(ActionRequest request, ActionResponse response) { long bookId = ParamUtil.getLong(request, "bookId"); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute( WebKeys.THEME_DISPLAY); if (Validator.isNotNull(bookId)) { BooksLocalServiceUtil.deleteBooks(bookId, themeDisplay.getCompanyId()); SessionMessages.add(request, "book-deleted"); } else { SessionErrors.add(request, "error-deleting"); } } */ } </code></pre> <p>This is my new error trace...</p> <pre><code>14:16:50,870 INFO [RestaurantPortlet:35] Inside addRegistration 14:16:50,872 INFO [RestaurantPortlet:40] {Resto_ID=0, Name=dasd, Location=ads, Room_Count=2, Table_Count=1, userId=10196, companyId=10154, groupId=10180, Reseller_ID=55} com.liferay.portal.ResourceActionsException: There are no actions associated with the resource com.test.model.Restaurant at com.liferay.portal.service.impl.ResourceLocalServiceImpl.validate(ResourceLocalServiceImpl.java:1348) at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addResources(ResourceLocalServiceImpl.java:845) at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addResources(ResourceLocalServiceImpl.java:147) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) </code></pre> <p>........... ............. 14:16:50,878 ERROR [RestaurantPortlet:43] REsto was Found Null</p> <p>My Action Resource mapping xml..</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;resource-action-mapping&gt; &lt;portlet-resource&gt; &lt;portlet-name&gt;RestaurantPortlet&lt;/portlet-name&gt; &lt;permissions&gt; &lt;supports&gt; &lt;action-key&gt;addRestaurant&lt;/action-key&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/supports&gt; &lt;community-defaults&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/community-defaults&gt; &lt;guest-defaults&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/guest-defaults&gt; &lt;guest-unsupported&gt; &lt;action-key&gt;addRestaurant&lt;/action-key&gt; &lt;/guest-unsupported&gt; &lt;/permissions&gt; &lt;/portlet-resource&gt; &lt;model-resource&gt; &lt;model-name&gt;com.test.Restaurant&lt;/model-name&gt; &lt;portlet-ref&gt; &lt;portlet-name&gt;RestaurantPortlet&lt;/portlet-name&gt; &lt;/portlet-ref&gt; &lt;permissions&gt; &lt;supports&gt; &lt;action-key&gt;addRestaurant&lt;/action-key&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/supports&gt; &lt;community-defaults&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/community-defaults&gt; &lt;guest-defaults&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/guest-defaults&gt; &lt;guest-unsupported&gt; &lt;/guest-unsupported&gt; &lt;/permissions&gt; &lt;/model-resource&gt; &lt;/resource-action-mapping&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload