Getting 'entityNameToMatch argument cannot be null' error in the logs

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

問題

You have custom layouts or user macros in Confluence Admin >> Layouts or Confluence Admin >> User Macros

And the following error appears in the atlassian-confluence.log:

2013-04-23 01:32:36,054 ERROR [http-8080-21] [confluence.util.velocity.VelocityUtils] getRenderedContent Error occurred rendering template content
– url: /display/test9/test | page: 2222292 | userName: anonymous | action: viewpage
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getGroupNamesForUserName' in  class $Proxy31 threw exception 
java.lang.IllegalArgumentException: entityNameToMatch argument cannot be null at getRenderedContent[line 84, column 40]

 

原因

Any call to a function that expects a username argument (  $req.userPrincipal.name ) such as the following in any layouts (space or global level) or user macros:

$userAccessor.getGroupNamesForUserName($req.userPrincipal.name)

Notice that the function "getGroupNamesForUserName" is highlighted in the error above. The error will be thrown whenever an anonymous user tries to view the page that has that layout, or user macro.

ソリューション

  • Look for any function calls that pass $req.userPrincipal.name as an argument, such as the user macro below:

    #set ($mygroupList = $userAccessor.getGroupNamesForUserName($req.userPrincipal.name))
    #end
    
    Hello, $mygroupList , $req.userPrincipal.name
  • Check whether  $req.userPrincipal.name is null before calling the function. Example:

    #if($req.userPrincipal.name)
    #set ($mygroupList = $userAccessor.getGroupNamesForUserName($req.userPrincipal.name))
    #end
    
    Hello, $mygroupList , $req.userPrincipal.name

    (add an if statement to check for null)

Last modified on Mar 30, 2016

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.