Problem using Hibernate Support and JSF
I have an application usig JSF + Spring. At the start I was using hard-coded DAO objects to access EIS layer. Then i decided to move to Hibernate, using Spring's templates. The fact is that when i use Hibernate, the application does not work, there's an error which causes my backing beans in the presentation layer fail. I have made some debuging, and came to the conclusion that this line (present in all backing beans) is the one causing troubles.
appContext = WebApplicationContextUtils.getRequiredWebApplicati onContext(context);
The application context xml file is:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- DataSource Definition -->
<bean id="mydataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@127.0.0.1:1521:LICAPALC</value>
</property>
<property name="username">
<value>adminlicapa</value>
</property>
<property name="password">
<value>adaptacion</value>
</property>
</bean>
<!-- Spring Data Access Exception Translator Defintion -->
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource"><ref bean="mydataSource"/></property>
</bean>
<!--Definicion del DAO de categoria-->
<bean id="categoriaDao" class="co.edu.unal.licapa.model.dao.hibernate.CategoriaDaoHibernateImpl">
<property name="hibernateTemplate"><ref bean="hibernateTemplate"/></property>
</bean>
<!-- Administracion de Capacitacion Virtual Service Defintion -->
<bean id="administracionVirtualService" class="co.edu.unal.licapa.model.service.impl.ServiceAdministracionVirtualImpl">
<property name="categoriaDao"><ref local="categoriaDao"/></property>
</bean>
<!-- Hibernate Template Defintion -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate.HibernateTemplate">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
<property name="jdbcExceptionTranslator"><ref bean="jdbcExceptionTranslator"/></property>
</bean>
<!-- Hibernate SessionFactory Definition -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>co/edu/unal/licapa/model/bo/Categoria.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.cache.provider_class">net.sf.hibernate.cache.HashtableCacheProvider</prop>
</props>
</property>
<property name="dataSource">
<ref bean="mydataSource"/>
</property>
</bean>
</beans>
Notice that the application works well with the next context:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/ spring-beans.dtd">
<beans>
<!-- DataSource Definition -->
<bean id="mydataSource" class="org.apache.commons.dbcp.Basic
DataSource" destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@127.0.0.1:1521:LICAPALC</value>
</property>
<property name="username">
<value>adminlicapa</value>
</property>
<property name="password">
<value>adaptacion</value>
</property>
</bean>
<!-- Spring Data Access Exception Translator Defintion -->
<bean id="jdbcExceptionTranslator"
class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource"><ref bean="mydataSource"/></property>
</bean>
<!--Definicion del DAO de categoria-->
<bean id="categoriaDao"
class="co.edu.unal.licapa.model.dao.jdbc.CategoriaDaoJdbcImpl2">
<property name="dataSource"><ref
bean="mydataSource"/></property>
</bean>
<!-- Administracion de Capacitacion Virtual Service Defintion -->
<bean id="administracionVirtualService"
class="co.edu.unal.licapa.model.service.impl.ServiceAdministracionVirtua
lImpl">
<property name="categoriaDao"><ref
local="categoriaDao"/>
</property>
</bean>
</beans>
Any Ideas? I'm in a hurry, plz help! :?:
Julian