cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.IllegalArgumentException: FacesContext must not be

andrepra
Champ in-the-making
Champ in-the-making
Hi,
I have a problem configuring a custom action configured on a Share event (Alfresco 3.3g). I would create a notification on creation of a new post in the Share site discussion. I developed the custom action and i configured it on the event "create" on the root folder "Sites". Trying the action with Alfresco web client works fine. 
When I create a post in a Share site correctly fires the action, but when I try to get the information from the RepositoryService about the new node I get an exception

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:584)
at org.alfresco.web.bean.repository.Node.getServiceRegistry(Node.java:514)
at org.alfresco.web.bean.repository.Node.getType(Node.java:306)
at it.quix.share.todolist.action.executer.ToDoListNotificationAction.getDashletActive(ToDoListNotificationAction.java:232)
at it.quix.share.todolist.action.executer.ToDoListNotificationAction.access$100(ToDoListNotificationAction.java:28)
at it.quix.share.todolist.action.executer.ToDoListNotificationAction$1.doWork(ToDoListNotificationAction.java:72)
at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
at it.quix.share.todolist.action.executer.ToDoListNotificationAction.executeImpl(ToDoListNotificationAction.java:110)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:133)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:726)
at org.alfresco.repo.action.executer.CompositeActionExecuter.executeImpl(CompositeActionExecuter.java:66)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:133)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:726)
at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:658)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1$1.execute(AsynchronousActionExecutionQueueImpl.java:494)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:321)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:228)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1.doWork(AsynchronousActionExecutionQueueImpl.java:503)
at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper.run(AsynchronousActionExecutionQueueImpl.java:506)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)

Performing a simple login to the Alfresco web client e repeating the post submition in Share everything works fine.
It seems that the FacesContext is initialized only at the first login. I found a similar post here

http://forums.alfresco.com/en/viewtopic.php?f=4&t=26224

but there's no response.
Thanks
3 REPLIES 3

kevinr
Star Contributor
Star Contributor
The problem here is that you are using beans that reference the JSF context. This is only initialised if you use the Alfresco Explorer client (a JSF app). The correct procedure is to use Spring injection of the bean definitions that you require for your action bean - you should not try and get references to services etc. via any kind of "helper" class you might have found - as in this case it is not the context to use it. The Node and Repository classes are part of the web-client package - and are only of use to the web-client itself i.e. not repository level classes.

Examples of Spring bean injection of services can be seen all over Alfresco config, for example the Action Service itself:

    <!– Action Service –>
    <bean id="actionService" class="org.alfresco.repo.action.ActionServiceImpl" init-method="init">
        <property name="policyComponent">
            <ref bean="policyComponent" />
        </property>        
        <property name="nodeService">
            <ref bean="NodeService" />
        </property>        
        <property name="searchService">
            <ref bean="ADMSearchService" />
        </property>        
        <property name="authenticationContext">
            <ref bean="authenticationContext" />
        </property>       
        <property name="actionTrackingService">
            <ref bean="actionTrackingService" />
        </property>       
        <property name="dictionaryService">
            <ref bean="DictionaryService" />
        </property>

You just need a setter method for each service you want.

Thanks,

Kev

sigpaolo
Champ in-the-making
Champ in-the-making
Hi, thank you for the suggestions. I still have the problem. I have modified the code as you said. Here below you can find the components of the bean used. Is there still one of the components that refers to JSF context? If any, pleasse confirm, or have you got any other suggestion?


   <bean id="discussionsPopulator" class="it.quix.share.todolist.populator.DiscussionsPopulator">
         <property name="permissionService" ref="PermissionService" />
         <property name="authorityService" ref="AuthorityService" />
         <property name="personService" ref="PersonService" />
         <property name="nodeService" ref="NodeService" />
         <property name="contentService" ref="ContentService" />
   </bean>

Thnx and regards,
Paolo

kevinr
Star Contributor
Star Contributor
The Node and Repository classes- in-fact anything in the web packages. For an action running in the repo (which you have) you should only use repository level services and deal directly with NodeRef objects not wrap them in a web class.

Hope this helps,

Kev
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.