AnsweredAssumed Answered

getting faces context instance in the java backed web script

Question asked by amarendra.thakur on Apr 16, 2010
Latest reply on May 5, 2010 by amarendra.thakur
Dear All,

I have written a java backed web script in which i am using the search service

      SearchParameters sp = new SearchParameters();
           sp.addStore(Repository.getStoreRef());
           sp.setLanguage(SearchService.LANGUAGE_LUCENE);
           sp.setQuery(qryString.toString());


From the resutl set i am getting the node list of nodes

e.g.

results = searchService.query(sp);
if(results!=null && results.length()>0)
{
for(ResultSetRow row : results)
{
NodeRef currentNodeRef = row.getNodeRef();
alfNode = new Node(currentNodeRef);
}
}


while accessing the properties of the node (alfNode.getProperties()) i am getting the exception "java.lang.IllegalArgumentException: FacesContext must not be null"

the complete stack trace is


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 org.alfresco.web.bean.repository.Repository.getUserTransaction(Repository.java:579)
        at com.undp.se.search.SearchResourceAction.searchResource(SearchResourceAction.java:84)
        at com.undp.se.action.SearchAction.executeImpl(SearchAction.java:45)
        at org.alfresco.web.scripts.DeclarativeWebScript.executeImpl(DeclarativeWebScript.java:209)
        at org.alfresco.web.scripts.DeclarativeWebScript.executeImpl(DeclarativeWebScript.java:223)
        at org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:70)
        at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:358)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:326)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:408)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:425)
        at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:289)
        at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:262)
        at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)
        at org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)


I have to login to the alfresco application once in order to avoid this exception.

I am also initializing the resquired services in the "web-scripts-application-context.xml" e.g.

   <bean id="webscript.com.abc.xyz.search.search.post"
         class="com.abc.xyz.action.SearchAction"
         parent="webscript">
         <property name="searchService" ref="SearchService" />
         <property name="nodeService" ref="nodeService" />
         <property name="dictionaryService" ref="dictionaryService" />        
   </bean>


I am using the alfresco 3.2 community edition

Unable to find what could be problem.

Required suggestion.

Thanks & Regards

Amarendra Thakur

Outcomes