[Spring+Hibernate]Invalid property
I have exception in my project, i don't know how i can correct this exception???
Code:
14.02.2012 20:48:15 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet springapp
org.springframework.beans.NotWritablePropertyException: Invalid property 'factory' of bean class [springapp.dao.lmpl.ClientIpDAOlmpl]: Bean property 'factory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
ClientIpDAOlmpl
Code:
public class ClientIpDAOlmpl implements ClientIpDAO{
private SessionFactory factory=null;
public SessionFactory getFactory() {
return factory;
}
public void setFactory(SessionFactory factory) {
this.factory = factory;
}
public void addClientIP(ClientIP id)throws SQLException{
Session session = null;
try{
session = factory.getCurrentSession();
session.beginTransaction();
session.save(id);
session.getTransaction().commit();
}catch(Exception ex){
System.out.println("Error in addClientIP" + ex.getMessage());
}finally{
if(session != null && session.isOpen()){
session.close();
}
}
}
public boolean authenticationClient(String ip, String alias, String pass)throws SQLException{
Session session = null;
boolean b = false;
ClientIP client;
try{
session = factory.getCurrentSession();
session.beginTransaction();
client = (ClientIP)session.get(ClientIP.class,ip);
session.getTransaction().commit();
if(client.getClientAlias().equals(alias) && client.getClientPass().equals(pass)){
b = true;
}
else
b = false;
}catch(Exception ex){
System.out.println("Error in auntificClient" + ex.getMessage());
}finally{
if(session != null && session.isOpen()){
session.close();
}
}
return b;
}
public void deleteClientIP(ClientIP id) throws SQLException{
Session session = null;
try{
session = factory.openSession();
session.beginTransaction();
session.delete(id);
session.getTransaction().commit();
}catch(Exception ex){
System.out.println("Error in deleteClientIP" + ex.getMessage());
}finally{
if(session != null && session.isOpen()){
session.close();
}
}
}
}
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/jdbc.properties" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.databaseurl}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>springapp/hibernate_logic/ClientIP.hbm.xml</value>
<value>springapp/hibernate_logic/StartProcess.hbm.xml</value>
<value>springapp/hibernate_logic/BlockedProcess.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
<bean id="myClientDAO" class="springapp.dao.lmpl.ClientIpDAOlmpl">
<property name="factory" ref="mySessionFactory" />
</bean>
<bean name="/mainNew.htm" class="springapp.web.ClientIpController">
<property name="clientDAO" ref="myClientDAO" />
</bean>
<!-- the application context definition for the springapp DispatcherServlet -->
<bean id="productManager" class="springapp.service.SimpleProductManager">
<property name="products">
<list>
<ref bean="product1"/>
<ref bean="product2"/>
<ref bean="product3"/>
</list>
</property>
</bean>
<bean id="product1" class="springapp.domain.Product">
<property name="description" value="Lamp"/>
<property name="price" value="5.75"/>
</bean>
<bean id="product2" class="springapp.domain.Product">
<property name="description" value="Table"/>
<property name="price" value="75.25"/>
</bean>
<bean id="product3" class="springapp.domain.Product">
<property name="description" value="Chair"/>
<property name="price" value="22.79"/>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"/>
</bean>
<bean name="/hello.htm" class="springapp.web.InventoryController">
<property name="productManager" ref="productManager"/>
</bean>
<bean name="/priceincrease.htm" class="springapp.web.PriceIncreaseFormController">
<property name="sessionForm" value="true"/>
<property name="commandName" value="priceIncrease"/>
<property name="commandClass" value="springapp.service.PriceIncrease"/>
<property name="validator">
<bean class="springapp.service.PriceIncreaseValidator"/>
</property>
<property name="formView" value="priceincrease"/>
<property name="successView" value="hello.htm"/>
<property name="productManager" ref="productManager"/>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
Code:
public class ClientIpController extends MultiActionController{
private ClientIpDAO clientDAO;
public void setClientDAO(ClientIpDAO clientDAO){
this.clientDAO = clientDAO;
}
public ClientIpDAO getClientDAO(){
return clientDAO;
}
public ModelAndView add(HttpServletRequest arg0,
HttpServletResponse arg1,ClientIP clientIp) throws Exception {
// TODO Auto-generated method stub
clientDAO.addClientIP(clientIp);
return new ModelAndView("hello");
}
}