Buggy code:
@ Dependent @ Stateful public class ForumController { @ Inject private SessionController sessionController ; @ Inject private EnvironmentForumAreaDAO environmentForumAreaDAO ; @ Inject private WorkspaceForumAreaDAO workspaceForumAreaDAO ; @ Inject private ForumAreaDAO forumAreaDAO ; @ Inject private ForumThreadDAO forumThreadDAO ; @ Inject private ForumMessageDAO forumMessageDAO ; @ Inject private ForumAreaGroupDAO forumAreaGroupDAO ; @ Inject private ForumThreadReplyDAO forumThreadReplyDAO ; @ Inject private ResourceRightsController resourceRightsController ; @ Inject private UserEntityController userEntityController ; @ Inject private UserController userController ; public ForumArea getForumArea ( Long forumAreaId ) { } public ForumThread getForumThread ( Long threadId ) { } public ForumThreadReply getForumThreadReply ( Long threadReplyId ) { } @ Permit ( ForumResourcePermissionCollection . FORUM_CREATEENVIRONMENTFORUM ) public EnvironmentForumArea createEnvironmentForumArea ( String name , Long groupId ) { UserEntity owner = sessionController . getLoggedUserEntity ( ) ; ResourceRights rights = resourceRightsController . create ( ) ; <START_BUG> ForumAreaGroup group = findForumAreaGroup ( groupId ) ; <END_BUG> return environmentForumAreaDAO . create ( name , group , false , owner , rights ) ; } public ForumAreaGroup findForumAreaGroup ( Long groupId ) { } @ Permit ( ForumResourcePermissionCollection . FORUM_WRITEAREA ) public ForumThread createForumThread ( @ PermitContext ForumArea forumArea , String title , String message , Boolean sticky , Boolean locked ) { } @ Permit ( ForumResourcePermissionCollection . FORUM_WRITEAREA ) public ForumThreadReply createForumThreadReply ( @ PermitContext ForumThread thread , String message ) { } public List < EnvironmentForumArea > listEnvironmentForums ( ) { } public List < WorkspaceForumArea > listCourseForums ( ) { } public List < WorkspaceForumArea > listCourseForums ( WorkspaceEntity workspace ) { } @ Permit ( ForumResourcePermissionCollection . FORUM_LISTTHREADS ) public List < ForumThread > listForumThreads ( @ PermitContext ForumArea forumArea , int firstResult , int maxResults ) { } @ Permit ( ForumResourcePermissionCollection . FORUM_LISTTHREADS ) public List < ForumThreadReply > listForumThreadReplies ( @ PermitContext ForumThread forumThread , Integer firstResult , Integer maxResults ) { } public List < ForumThread > listLatestForumThreads ( int firstResult , int maxResults ) { } public UserEntity findUserEntity ( Long userEntityId ) { } public User findUser ( UserEntity userEntity ) { } public boolean getUserHasPicture ( UserEntity userEntity ) { } public ForumThreadReply getLatestReply ( ForumThread thread ) { } public ForumMessage getLatestMessage ( ForumArea area ) { } public Long getThreadReplyCount ( ForumThread thread ) { } public Long getThreadCount ( ForumArea area ) { } public Long getMessageCount ( ForumArea area ) { } public void archiveMessage ( ForumMessage message ) { } public void updateForumThread ( ForumThread thread , String title , String message , Boolean sticky , Boolean locked ) { } public void updateForumThreadReply ( ForumThreadReply reply , String title , String message , Boolean sticky , Boolean locked ) { } public List < ForumAreaGroup > listForumAreaGroups ( ) { } public ForumAreaGroup createForumAreaGroup ( String name ) { } public List < ForumMessage > listMessagesByWorkspace ( WorkspaceEntity workspace ) { } public List < ForumMessage > listByContributingUser ( UserEntity userEntity ) { } }

Fix:
ForumAreaGroup group = ( groupId != null ) ? findForumAreaGroup ( groupId ) : null ;