AnsweredAssumed Answered

java.lang.IllegalArgumentException: FacesContext must not be

Question asked by blue12 on Apr 13, 2010
We copy files over a filemount in the alfresco system. On the target folder we have an action running. We see the following behaviour – if nobody ever before calls the web interface we get a “FacesContext must not be null” Exception. Just one call to the web application will fix the problem. Here is the stack trace:

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 org.alfresco.web.bean.repository.Node.getServiceRegistry(Node.java:520)
at org.alfresco.web.bean.repository.Node.getAspects(Node.java:345)
at org.alfresco.web.bean.repository.Node.hasAspect(Node.java:357)
at dm.model.ContentUtils.writeAthleticDataToNode(ContentUtils.java:76)
at dm.action.DSAActionExectuter.writeAthleticDataToNode(DSAActionExectuter.java:254)
at dm.action.AthleticOptInAction.executeImplException(AthleticOptInAction.java:56)
at dm.action.DSAActionExectuter.executeImpl(DSAActionExectuter.java:60)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:127)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:688)
at org.alfresco.repo.action.executer.CompositeActionExecuter.executeImpl(CompositeActionExecuter.java:72)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:127)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:688)
at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:625)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1$1.execute(AsynchronousActionExecutionQueueImpl.java:369)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:322)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:229)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1.doWork(AsynchronousActionExecutionQueueImpl.java:378)
at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:497)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper.run(AsynchronousActionExecutionQueueImpl.java:381)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)

Is it a correct notice that the RepositoryService needs just one reference to webapplication context – even if it is not the current context?
If yes – why does the RepositoryService needs a WebApplication context? – I understand it more as a backend service independent from the type of caller.
Or do we make

Here a test class that reproduces the described behaviour:

package dm.action;

import java.util.List;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.apache.log4j.Logger;

public class TestAction extends ActionExecuterAbstractBase {

   private static Logger logger = Logger.getLogger(TestAction.class);

   @Override
   protected void executeImpl(Action arg0, NodeRef nodeRef) {
      Node node = new Node(nodeRef);
      
      if(!node.hasAspect(QName.createQName("testaspect"))) {
         logger.debug("as expected the aspect does not exist");
      }
   }

   @Override
   protected void addParameterDefinitions(List<ParameterDefinition> arg0) {
   }


}
We are using the enterprise version 3.1.0.

Thanks Georg

Outcomes