AnsweredAssumed Answered

Constraint problem updating 3.2 preview to  3.2 community

Question asked by jarrett on Jul 13, 2009
Latest reply on Jul 20, 2009 by jayjayecl
A custom constrain we wrote that returns the members of a group fails during start up after upgrading 3.2 preview to 3.2 community. Java is not my strong suit so any help would be appreciated. I think all the relevant information has been included, if I've missed anything please let me know.

Excerpt from faces-config-custom.xml
<managed-bean>
        <description>Group Member Constraint</description>
        <managed-bean-name>GroupMembersConstraint</managed-bean-name>
        <managed-bean-class>com.efoundry.alfresco.constraints.GroupMembersConstraint</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

Excerpt from model:

<!–  seed value for Members of the Analyst Group –>
<constraint name="ygwf:AnalystConstraint" type="com.efoundry.alfresco.constraints.GroupMembersConstraint">
        <parameter name="allowedValues">
                <list><value>GROUP_Analyst</value></list>
        </parameter>
</constraint>

Excerpt from constraint:
    public List<String> getAllowedValues() {
        logger.info( "getAllowedValues()" );
        System.out.println("getAllowedValues()");
        ArrayList<String> list = new ArrayList<String>();

        List<String> groupMembers = super.getAllowedValues();
        groupMembers = getMemberList( groupMembers.get(0) );

      PersonService personService =  Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getPersonService();
      NodeService nodeService =  Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();

        for( String memberName : groupMembers ) {
           StringBuffer sb = new StringBuffer();
           sb.append( memberName );
           sb.append( " - " );
           NodeRef memberNodeRef = personService.getPerson( memberName );
           sb.append( nodeService.getProperty( memberNodeRef, org.alfresco.model.ContentModel.PROP_FIRSTNAME ) );
           sb.append( " " );
           sb.append( nodeService.getProperty( memberNodeRef, org.alfresco.model.ContentModel.PROP_LASTNAME ) );
           /*sb.append( " (" );
           sb.append( groupMembers.get(0) );
           sb.append( ")" ); */
           
           list.add( sb.toString() );   
        }

        return list;
    }

The error from catalina.out:
getAllowedValues()
18:08:16,829 User:System ERROR [web.context.ContextLoader] Context initialization failed
java.lang.IllegalArgumentException: FacesContext must not be null
        at org.springframework.util.Assert.notNull(Assert.java:112)
        at org.springframework.web.jsf.FacesContextUtils.getWebApplicationContext(FacesContextUtils.java:50)
        at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:81)
        at org.alfresco.web.bean.repository.Repository.getServiceRegistry(Repository.java:593)
        at com.efoundry.alfresco.constraints.GroupMembersConstraint.getMemberList(GroupMembersConstraint.java:80)
        at com.efoundry.alfresco.constraints.GroupMembersConstraint.getAllowedValues(GroupMembersConstraint.java:108)
        at org.alfresco.cmis.dictionary.CMISBasePropertyDefinition.<init>(CMISBasePropertyDefinition.java:108)
        at org.alfresco.cmis.dictionary.CMISAbstractTypeDefinition.createProperty(CMISAbstractTypeDefinition.java:126)
        at org.alfresco.cmis.dictionary.CMISAbstractTypeDefinition.createProperties(CMISAbstractTypeDefinition.java:104)
        at org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.init(CMISAbstractDictionaryService.java:394)
        at org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.afterDictionaryInit(CMISAbstractDictionaryService.java:465)
        at org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.onBootstrap(CMISAbstractDictionaryService.java:483)
        at org.alfresco.util.AbstractLifecycleBean.onApplicationEvent(AbstractLifecycleBean.java:62)
        at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
        at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:617)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
        at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:69)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 10, 2009 6:08:16 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Jul 10, 2009 6:08:16 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/alfresco] startup failed due to previous errors

Outcomes