如何解决这个java.lang.NoSuchMethodException:com.liferay.util.bridges.mvc.MVCPortlet。#######?

时间:2012-10-20 05:35:07

标签: liferay portlet liferay-6

在使用其他自定义portlet调用一个add函数时,再次遇到同样问题。 我在我的portlet类中有一个使用addrestaurant(餐厅)的方法,当我从我的视图中调用它来添加数据时,它会给我以下错误。

05:27:42,752 ERROR [http-bio-8080-exec-4][render_portlet_jsp:154] java.lang.NoSuchMethodException: com.liferay.util.bridges.mvc.MVCPortlet.addrestaurant(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
    at java.lang.Class.getMethod(Class.java:1605)
    at com.liferay.portal.kernel.util.MethodCache._get(MethodCache.java:123)
    at com.liferay.portal.kernel.util.MethodCache.get(MethodCache.java:45)
    at com.liferay.portal.kernel.portlet.LiferayPortlet.callActionMethod(LiferayPortlet.java:149)
    at com.liferay.util.bridges.mvc.MVCPortlet.callActionMethod(MVCPortlet.java:250)
    at com.liferay.portal.kernel.portlet.LiferayPortlet.processAction(LiferayPortlet.java:80)
    at com.liferay.util.bridges.mvc.MVCPortlet.processAction(MVCPortlet.java:220)
    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
    at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)

我检查了所有的东西,但仍然没有理由我发现为什么会发生这种情况..当我创建新的portlet时,每次都知道它...

以下是我的restaurantportlet.java类

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<String> errors=new ArrayList<String>();


        restaurant rest=RestaurantActionUtil.getRestaurantFromRequest(request);
        boolean bookValid=RestaurantValidator.validateRestaurant(rest,errors);
        if(bookValid) {
            try {
                log.info(rest);
                restaurant test=restaurantLocalServiceUtil.addrestaurant(rest);
                if(test==null) {
                    log.error("Restaurant was Found Null");
                    response.setRenderParameter("jspPage", errorJSP);
                    return ;
                }
            } catch (SystemException e) {
                log.error(e);
                /*If there is an error then divert the control to the error page.*/
                response.setRenderParameter("jspPage", errorJSP);
                return ;
            }
            SessionMessages.add(request,"restaurant-added");
            return ;
        }
        else {
             for (String error : errors) {
                    SessionErrors.add(request, error);
                }
                SessionErrors.add(request, "error-while-adding");
                request.setAttribute("rest",rest);
                return ;
        }

    }

以下是我的restaurantImpl.java类

 */
public class restaurantLocalServiceImpl extends restaurantLocalServiceBaseImpl {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never reference this interface directly. Always use {@link emenu.advertise.database.service.restaurantLocalServiceUtil} to access the restaurant local service.
     */
    public restaurant addrestaurant(restaurant restParam) {
        restaurant restVar;

        try {
            restVar = restaurantPersistence.create(counterLocalService
                    .increment(advertise.class.toString()));
        } catch (SystemException e) {
            e.printStackTrace();
            return restVar = null;
        }

        try {
            resourceLocalService.addResources(restParam.getGroupId(), restParam.getUserId(),
                    advertise.class.getName(), false);
        } catch (PortalException e) {
            e.printStackTrace();
            return restVar = null;
        } catch (SystemException e) {
            e.printStackTrace();
            return restVar = null;
        }

        restVar.setName(restParam.getName());
        restVar.setAdress(restParam.getAdress());
        restVar.setCity(restParam.getCity());
        restVar.setPin(restParam.getPin());
        restVar.setState(restParam.getState());
        restVar.setCountry(restParam.getCountry());
        restVar.setContactno(restParam.getContactno());
        restVar.setEmail(restParam.getEmail());
        restVar.setWebsite(restParam.getWebsite());
        restVar.setCuisinetype(restParam.getCuisinetype());
        restVar.setPersonalmail(restParam.getPersonalmail());
        restVar.setPersonalname(restParam.getPersonalname());
        restVar.setPersonalPhone(restParam.getPersonalPhone());
        restVar.setNoofemenuagent(restParam.getNoofemenuagent());
        restVar.setLicensekey(restParam.getLicensekey());
        restVar.setRestregId(restParam.getRestId());
        restVar.setNoofdiningtable(restParam.getNoofdiningtable());
        restVar.setAvgnoofcustomermonthly(restParam.getAvgnoofcustomermonthly());
        restVar.setAveragroupagevisit(restParam.getAveragroupagevisit());
        restVar.setImpoflocation(restParam.getImpoflocation());
        restVar.setAvgmonthlycheckamount(restParam.getAvgmonthlycheckamount());
        restVar.setCostperthousandimpression(restParam.getCostperthousandimpression());
        restVar.setAdtypeId(restParam.getAdtypeId());
        //restVar.setNoofdiningtable(restParam.getNoofdiningtable());
        //restVar.setAvgnoofcustomermonthly(restParam.getAvgnoofcustomermonthly());


        restVar.setIsactive(restParam.getIsactive());
        restVar.setCreateddate(restParam.getCreateddate());
        restVar.setLastmodifiedby(restParam.getLastmodifiedby());
        restVar.setModifieddate(restParam.getModifieddate());
        restVar.setGroupId(restParam.getGroupId());
        restVar.setUserId(restParam.getUserId());
        restVar.setIsdeleted(restParam.getIsdeleted());
        restVar.setRestregId(restParam.getRestregId());

        //restVar.setOrganizationId(restParam.getOrganizationId());

        try {
            return restaurantPersistence.update(restVar, false);
        } catch (SystemException e) {
            e.printStackTrace();
            return restVar = null;
        }
    }

以下是我的restuarntActionutil类

public class RestaurantActionUtil {



        public static restaurant getRestaurantFromRequest(ActionRequest request) {
            ThemeDisplay themeDisplay = (ThemeDisplay) request
                    .getAttribute(WebKeys.THEME_DISPLAY);
            String name = ParamUtil.getString(request, "name",
                    "name Not Availible");
                    restaurant rest  = new restaurantImpl();
            rest.setName(name);
            rest.setLicensekey(ParamUtil.getString(request, "licesnce_key"));
            rest.setCity(ParamUtil.getString(request, "city"));
            rest.setPin(ParamUtil.getString(request, "pin"));
            rest.setAdress(ParamUtil.getString(request, "adress"));
            rest.setState(ParamUtil.getString(request, "state"));
            rest.setCountry(ParamUtil.getString(request, "country"));
            rest.setContactno(ParamUtil.getString(request, "contact_no"));
            rest.setEmail(ParamUtil.getString(request, "email"));
            rest.setWebsite(ParamUtil.getString(request, "website"));
            rest.setCuisinetype(ParamUtil.getString(request, "cuisine_type"));
            rest.setNoofemenuagent(ParamUtil.getInteger(request, "no_of_emenu_agent"));
            rest.setNoofdiningtable(ParamUtil.getInteger(request, "no_of_dining_table"));
            rest.setPersonalname(ParamUtil.getString(request, "personal_name"));
            rest.setPersonalPhone(ParamUtil.getString(request, "personal_phone"));
            rest.setPersonalmail(ParamUtil.getString(request, "personal_mail"));
            rest.setAveragroupagevisit(ParamUtil.getInteger(request, "avg_age_group_people"));
            rest.setImpoflocation(ParamUtil.getString(request, "imp_of_location"));
            rest.setAvgnoofcustomermonthly(ParamUtil.getInteger(request, "avg_no_of_cust_monthly"));
            rest.setAvgmonthlycheckamount(ParamUtil.getInteger(request, "avg_monthly_check_amount"));
            rest.setAvgmonthlycheckamount(ParamUtil.getLong(request, "cost_per_thousand_impressions"));
            rest.setAdtypeId(ParamUtil.getInteger(request, "ad_type"));
            rest.setIsactive(ParamUtil.getBoolean(request, "isactive"));
            rest.setGroupId(themeDisplay.getLayout().getGroupId());
            rest.setUserId(themeDisplay.getUserId());
            rest.setCreateddate(Calendar.getInstance().getTime());
            rest.setModifieddate(Calendar.getInstance().getTime());
            rest.setLastmodifiedby(themeDisplay.getUserId());
            rest.setRestregId((ParamUtil.getLong(request, "licensekey")));
            rest.setIsdeleted(false);



                        return rest;
        }


    }

以下是我的view.jsp代码,从中调用此方法。

<liferay-portlet:actionURL name="addrestaurant" var="addrestoURL"></liferay-portlet:actionURL>

                      <form class="form_validation_ttip" action="<%= addrestoURL.toString()%>" method="post">            

这是我的按钮形式。

<button class="btn" name="btnback" >Save</button>
请任何人都可以指导我?我需要找到这背后的主要原因..所以从下次开始我会记住我在做错误的地方..

1 个答案:

答案 0 :(得分:0)

你能把portlet.xml放在这里吗? 看起来你没有指定你的类,所以Liferay试图使用默认的MVCPortlet类。当然,没有addrestaurant()方法。 这不是代码问题,而是配置问题。