Hi ,
I've been trying to implement some Spring ORM features in my Hibernate DAO's . After reading Bruce Tate's book on better / lighter java , and looking at the docs linked at the spring documentation page I came up with the following changes to implement in my Tapestry / Hibernate app :
i've added an applicationContext.xml file in my WEB-INFCode:public class IdsDAOImpl extends HibernateDaoSupport implements IdsDAO { private SessionFactory sessionFactory; /* Commented because it's overriden in 2 examples , yet final in the spring source public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } */ public IdsDAOImpl( ) { } public void someWritterMethod () { HibernateTemplate ht = getHibernateTemplate(); ... ...
modified web.xml to see the applicationContext.xmlCode:<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>jdbc/frd</value> </property> </bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="mappingResources"> <list> ... <value>Ids.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">net.sf.hibernate.dialect.PostgreSQLDialect</prop> </props> </property> <property name="dataSource"> <ref bean="myDataSource"/> </property> </bean> ... <bean id="idsDAO" class="sic.freddy.dao.hibernate.IdsDAOImpl"> <property name="sessionFactory"> <ref bean="mySessionFactory"/> </property> </bean>
When trying to run a test that accesses the someWritterMethod() , tomcat throws an NullPointerException at the line that I try to work with the HibernateTemplate object . I tested it and the object is null . No other exceptions are shown y Spring or Hibernate while deploying or running .Code:<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext.xml </param-value> </context-param>
Any ideeas / sugestions are greately apreciated .


Reply With Quote