cancel
Showing results for 
Search instead for 
Did you mean: 

FacesContext is null when I extend NavigationBean

rrobles
Champ in-the-making
Champ in-the-making
Hi,

      I have created CustomNavigationBean which extends of NavigationBean,




public class CustomNavigationBean extends NavigationBean
{
  … 
}
In custom-model-context.xml

<bean id="CustomNavigationBean" class="com.example.web.bean.search.CustomNavigationBean">
</bean>
In faces-config-custom.xml

<managed-bean>
      <description>
         The bean that holds navigation state.
      </description>
      <managed-bean-name>CustomNavigationBean</managed-bean-name>
      <managed-bean-class>com.example.web.bean.search.CustomNavigationBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
         <property-name>nodeService</property-name>
         <value>#{NodeService}</value>
      </managed-property>
      <managed-property>
         <property-name>searchService</property-name>
         <value>#{SearchService}</value>
      </managed-property>
      <managed-property>
         <property-name>namespaceService</property-name>
         <value>#{NamespaceService}</value>
      </managed-property>
      <managed-property>
         <property-name>serverConfiguration</property-name>
         <value>#{fileServerConfiguration}</value>
      </managed-property>
      <managed-property>
         <property-name>ruleService</property-name>
         <value>#{RuleService}</value>
      </managed-property>
      <managed-property>
         <property-name>userPreferencesBean</property-name>
         <value>#{UserPreferencesBean}</value>
      </managed-property>
      <managed-property>
         <property-name>authenticationService</property-name>
         <value>#{AuthenticationService}</value>
      </managed-property>
      <managed-property>
         <property-name>permissionService</property-name>
         <value>#{PermissionService}</value>
      </managed-property>
   </managed-bean>


but when I start alfresco I get next error

rror creating bean with name 'CustomNavigationBean' defined in file […./alfresco/WEB-INF/classes/alfresco/extension/custom-model-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.example.web.bean.search.CustomNavigationBean]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: FacesContext must not be null
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.example.web.bean.search.CustomNavigationBean]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: FacesContext must not be null
Caused by: 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.app.Application.getConfigService(Application.java:826)
        at org.alfresco.web.app.Application.getClientConfig(Application.java:851)
        at org.alfresco.web.bean.NavigationBean.initFromClientConfig(NavigationBean.java:1049)
        at org.alfresco.web.bean.NavigationBean.<init>(NavigationBean.java:103)
        at com.example.web.bean.search.CustomNavigationBean.<init>(CustomNavigationBean.java:105)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:85)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:757)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:722)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:386)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
        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(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Dec 28, 2010 11:36:49 AM org.apache.catalina.core.StandardContext start

Could anyone help me?

Thanks
3 REPLIES 3

patil
Champ on-the-rise
Champ on-the-rise
Hi,

Remove the entry from

In custom-model-context.xml remove the entry of the bean.
Provide setter and getter for all the properties configured in the managedbean tag.


Thanks,
Patil
Cignex Technologies
Bangalore

rrobles
Champ in-the-making
Champ in-the-making
I'll prove it.
Thanks, Patil.

mikepoole
Champ in-the-making
Champ in-the-making
I am getting the same problem. I've updated my faces-config-custom.xml file to have the following..

<managed-bean>
      <description>A customization of default NavigationBean bean</description>
      <managed-bean-name>NavigationBean</managed-bean-name>
      <managed-bean-class>org.xxx.CustomNavBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
         <property-name>nodeService</property-name>
         <value>#{NodeService}</value>
      </managed-property>
      <managed-property>
         <property-name>searchService</property-name>
         <value>#{SearchService}</value>
      </managed-property>
      <managed-property>
         <property-name>namespaceService</property-name>
         <value>#{NamespaceService}</value>
      </managed-property>
      <managed-property>
         <property-name>cifsServer</property-name>
         <value>#{cifsServer}</value>
      </managed-property>
      <managed-property>
         <property-name>ruleService</property-name>
         <value>#{RuleService}</value>
      </managed-property>
      <managed-property>
         <property-name>userPreferencesBean</property-name>
         <value>#{UserPreferencesBean}</value>
      </managed-property>
      <managed-property>
         <property-name>authenticationService</property-name>
         <value>#{AuthenticationService}</value>
      </managed-property>
        <managed-property>
            <property-name>permissionService</property-name>
            <value>#{PermissionService}</value>
        </managed-property>
   </managed-bean>

and created all my setters and getters in my bean

package org.xxx;

import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.users.UserPreferencesBean;

public class CustomNavBean extends NavigationBean {

   /**
    *
    */
   private static final long serialVersionUID = 1L;
   public NodeService nodeService;
   public SearchService searchService;
   public NamespaceService namespaceService;
   public RuleService ruleService;
   public AuthenticationService authenticationService;
   public PermissionService permissionService;
   public UserPreferencesBean userPreferencesBean;
   
   public String getCurrentNodeId(){
      return super.getCurrentNodeId();
   }
   
   //setters
   public void setNodeService(NodeService nodeService){
      this.nodeService = nodeService;
   }
   
   public void setSearchService(SearchService searchService){
      this.searchService = searchService;
   }
   
   public void setNamespaceService(NamespaceService namespaceService){
      this.namespaceService = namespaceService;
   }
   
   public void setRuleService(RuleService ruleService){
      this.ruleService = ruleService;
   }
   
   public void setAuthenticationService(AuthenticationService authenticationService){
      this.authenticationService = authenticationService;
   }
   
   public void setPermissionService(PermissionService permissionService){
      this.permissionService = permissionService;
   }
   
   public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean){
      this.userPreferencesBean = userPreferencesBean;
   }
   
   //getters
   public NodeService getNodeService(){
      return this.nodeService;
   }
   
   public SearchService getSearchService(){
      return this.searchService;
   }
   
   public NamespaceService getNamespaceService(){
      return this.namespaceService;
   }
   
   public RuleService getRuleService(){
      return this.ruleService;
   }
   
   public AuthenticationService getAuthenticationService(){
      return this.authenticationService;
   }
   
   public PermissionService getPermissionService(){
      return this.permissionService;
   }
   
   public UserPreferencesBean getUserPreferencesBean(){
      return this.userPreferencesBean;
   }
   
   
   
   
}

and I still get the java.lang.IllegalArgumentException: FacesContext must not be null error
What am I doing wrong? Is it anything to do with missing the cifsServer getter/setter (should this be cifsServerBean?)

Many thanks

Mike
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.