Spring & JSF integration: dao is null after jsf navigation

[email protected]
Newsgroups gmane.comp.java.springframework.user
Message-ID <[email protected]>
Hello all,
  I am trying to convert a JSF-iBatis dao application to JSF-Spring Dao. I have configured the spring dao and service layer objects and was able to successfully run the application, at least the first pages are displayed correctly with dao being able to fetch data from the database. However, when I navigate to the next page, the dao objects used in the service layer become null. What am i doing wrong. I have congured spring like follows:

spring.xml (all of spring related configurations went here)

    <!-- JNDI datasource -->
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName">
            <value>java:ds/CirDS</value>
        </property>
    </bean>

    <bean id="sqlMapClient"
          class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
        <property name="configLocation">
            <value>classpath:gov/bf/cir/services/dao/sql/sql-map-config.xml</value>
        </property>
        <property name="useTransactionAwareDataSource">
            <value>true</value>
        </property>
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>
    </bean>

    <bean id="sqlMapClientTemplate"
          class="org.springframework.orm.ibatis.SqlMapClientTemplate">
          <property name="sqlMapClient" ref="sqlMapClient"/>
    </bean>
 
    <!-- Dao -->
   <bean id="confDaoImp" class="gov.bf.cir.services.dao.impl.ConfDaoImpl">
        <property name="sqlMapClient" ref="sqlMapClient"/>                           
    </bean> 
    <bean id="deviseDaoImp" class="gov.bf.cir.services.dao.impl.DeviseDaoImpl">
        <property name="sqlMapClient" ref="sqlMapClient"/>
    </bean>                                                        
    <bean id="docDaoImp" class="gov.bf.cir.services.dao.impl.DocDaoImpl">
        <property name="sqlMapClient" ref="sqlMapClient"/>
    </bean>
     ....

    <!-- Services -->   
    <bean id="demDocService" class="gov.bf.cir.services.op.DemDocService">
          <property name="docDao" ref="docDaoImp"/>
          .... 
    </bean>



JSF Backing bean implementation: the service layer object is instantiated in the backing bean constructor.

public class DemDocForm implements Serializable
{
         private demService DemDocService;
         ...

        public DemDocForm() 
	{
		demService = SpringInit.getApplicationContext().getBean("demDocService"));
	}
}


Service implementation: the dao object should be injected into the service object every time it is instantiated. But it seem the dao are injected
only when the service object is first created when the backing bean is created. Don't know what happens after, if and when the 
backing bean is serialized and then deserialized.  The backing bean has scope "session" and face-config.xml does not contain anything specific to spring (old faces configuration for iBatis Dao).

public class DemDocService
{   
    private docDao DocDao;
    ...

    public DemDocService()
    {}

    public getDocDao(){
         return this.docDao;
    }

    public setDocDao( DocDao docDao)
    {
           this.docDao = docDao;
    }
}


Thanks in advance for any help.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.