cancel
Showing results for 
Search instead for 
Did you mean: 

AWMUtil tightly coupled with FacesContext

ebo
Champ in-the-making
Champ in-the-making
I am trying to use the AWMUtil from within a quartz scheduled job but because the AVMUtil requires a FacesContext some exceptions are been thrown:

java.lang.IllegalArgumentException: FacesContext must not be null
    at org.springframework.util.Assert.notNull(Assert.java:113)
    at org.springframework.web.jsf.FacesContextUtils.getWebApplicationContext(FacesContextUtils.java:50)
    at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:81)
    at org.alfresco.web.app.Application.getConfigService(Application.java:674)
    at org.alfresco.web.bean.wcm.AVMUtil.getDeploymentConfig(AVMUtil.java:1101)
    at org.alfresco.web.bean.wcm.AVMUtil.getRemoteDeploymentUsername(AVMUtil.java:305)

    at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:236)
    at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:166)

    at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)

Is there a another wat to go about this?
1 REPLY 1

gavinc
Champ in-the-making
Champ in-the-making
AVMUtil is a client side class and thus presumes that a JSF context is available. A scheduled job runs in the context of the repository (server) and so as you have found can not access or create the FacesContext.

Unfortunately, the config you are trying to access was put in the wrong place, it really belongs to the deployment action and should therefore be configured in Spring. This has been rectified in 2.2 (and now HEAD) where deployment has been overhauled, but that doesn't help you much 😞

If you can't move to 2.2 (which is only in beta at the moment) or a current nightly build then you'll have to create a config service bean that reads in the relevant config file (web-client-config-wcm.xml) and inject it into your scheduled job.