2013-04-25 71 views
0

我對我的服務生成器添加了一個新方法:的Liferay服務生成器不能識別功能

public IRRule ruleCreation() 
throws SystemException, PortalException { 
    IRRule rule = new IRRuleImpl(); 
    return rule; 
} 

的方法從portlet類公認的(沒有錯誤都):

public class RulePortlet extends MVCPortlet{ 

public void addRule(ActionRequest request, ActionResponse response) 
throws Exception { 
    ThemeDisplay themeDisplay = 
    (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY); 

    IRRule rule = IRRuleLocalServiceUtil.ruleCreation(); // This is The Method!!!! 


    rule.setCompanyId(themeDisplay.getCompanyId()); 
    rule.setGroupId(themeDisplay.getScopeGroupId()); 
    rule.setRuleName(ParamUtil.getString(request, "ruleName")); 
    rule.setRuleDescription(ParamUtil.getString(request, "ruleDescription")); 
    rule.setRuleFile(ParamUtil.getString(request, "ruleFile")); 

    ArrayList<String> errors = new ArrayList<String>(); 
    if (RuleValidator.validateRule(rule, errors)) { 
     IRRuleLocalServiceUtil.addRule(rule, 
     themeDisplay.getUserId()); 
     SessionMessages.add(request, "product-saved-successfully"); 
    } else { 
     SessionErrors.add(request, "fields-required"); 
    } 
} 
... 

但在測試此功能的時間我有這個錯誤拋出控制檯...

java.lang.NoSuchMethodError: com.ent.oriol.inputrules.service.IRRuleLocalServiceUtil.ruleCreation()Lcom/ent/oriol/inputrules/model/IRRule; 

這怎麼可能?我應該怎麼做才能解決這個問題?在過去,我將其他函數添加到服務構建器(LocalServiceImpl類)中,而不會出現任何問題!

謝謝你的幫助, 奧里奧爾

+0

您是否在構建服務時檢查了'ant-console'中是否有任何錯誤? – 2013-04-25 15:18:38

+0

我重新啓動了電腦,問題解決了。在測試時我沒有收到任何控制檯問題,我認爲這是線程問題! – user1592470 2013-04-26 07:33:24

回答

1

正如您所評論的那樣,重新啓動有幫助,問題可能是一些舊代碼以某種方式被緩存,也許在ar unning調試器進程沒有選擇重建服務時由servicebuilder引起的類更改。

在事實之後很難說出這一點 - 如果你能重現這一點,那麼瞭解情況會很有趣, IDE,測試設置等。否則,恐怕您必須將其視爲矩陣中的一個小故障。

-1
Goto service.xml--->select Overview--->In the right corner build services option is there--->click that 

enter image description here

如果service.xml中看到任何變化只要按照上面的畫面是什麼我提到你會糾正easily.In他在發言中提到的就像服務建設者所做的一些更改,這就是我給出解決方案的原因

+0

OP表示他之前在服務構建器中使用LocalServiceImpl構建了其他方法:***在過去,我將其他函數添加到了服務構建器(LocalServiceImpl類)中,而且沒有任何問題!***所以這並不回答我認爲的問題。 – 2013-04-25 11:39:50