spring2.5.1+webwork2.2.5+proxool0.9.1
启动tomcat异常如下,我看过ProxoolDataSource的源码,houseKeepingSleepTime的get/set方法返回值类型以及设值类型确实不一样,是导致下面异常的主要原因?我不太确定。有什么解决方案吗?:
Java代码
ERROR [main] org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/dataAccessContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'houseKeepingSleepTime' of bean class [org.logicalcobwebs.proxool.ProxoolDataSource]: Bean property 'houseKeepingSleepTime' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.NotWritablePropertyException: Invalid property 'houseKeepingSleepTime' of bean class [org.logicalcobwebs.proxool.ProxoolDataSource]: Bean property 'houseKeepingSleepTime' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:567)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:469)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:626)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:653)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:642)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1023)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:824)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
我的程序配置如下:
web.xml <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/dataAccessContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/dataAccessContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>dataAccessContext.xml <bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/conf/proxool-jdbc.properties</value>
</list>
</property>
</bean>
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" autowire="byName">
<property name="driver">
<value>${proxool.driver}</value>
</property>
<property name="driverUrl">
<value>${proxool.url}</value>
</property>
<property name="user">
<value>${proxool.username}</value>
</property>
<property name="password">
<value>${proxool.password}</value>
</property>
<property name="alias">
<value>${proxool.alias}</value>
</property>
<property name="houseKeepingSleepTime">
<value>90000</value>
</property>
</bean> <bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/conf/proxool-jdbc.properties</value>
</list>
</property>
</bean>
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" autowire="byName">
<property name="driver">
<value>${proxool.driver}</value>
</property>
<property name="driverUrl">
<value>${proxool.url}</value>
</property>
<property name="user">
<value>${proxool.username}</value>
</property>
<property name="password">
<value>${proxool.password}</value>
</property>
<property name="alias">
<value>${proxool.alias}</value>
</property>
<property name="houseKeepingSleepTime">
<value>90000</value>
</property>
</bean>
proxool-jdbc.properties proxool.driver=org.gjt.mm.mysql.Driver
proxool.username=xx
proxool.password=xx
proxool.url=jdbc:mysql://localhost:3306/xxx?useUnicode=true&characterEncoding=utf8&user=xx&password=xx
proxool.alias=xxx
启动tomcat异常如下,我看过ProxoolDataSource的源码,houseKeepingSleepTime的get/set方法返回值类型以及设值类型确实不一样,是导致下面异常的主要原因?我不太确定。有什么解决方案吗?:
Java代码
ERROR [main] org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/dataAccessContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'houseKeepingSleepTime' of bean class [org.logicalcobwebs.proxool.ProxoolDataSource]: Bean property 'houseKeepingSleepTime' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.NotWritablePropertyException: Invalid property 'houseKeepingSleepTime' of bean class [org.logicalcobwebs.proxool.ProxoolDataSource]: Bean property 'houseKeepingSleepTime' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:567)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:469)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:626)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:653)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:642)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1023)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:824)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
我的程序配置如下:
web.xml <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/dataAccessContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/dataAccessContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>dataAccessContext.xml <bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/conf/proxool-jdbc.properties</value>
</list>
</property>
</bean>
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" autowire="byName">
<property name="driver">
<value>${proxool.driver}</value>
</property>
<property name="driverUrl">
<value>${proxool.url}</value>
</property>
<property name="user">
<value>${proxool.username}</value>
</property>
<property name="password">
<value>${proxool.password}</value>
</property>
<property name="alias">
<value>${proxool.alias}</value>
</property>
<property name="houseKeepingSleepTime">
<value>90000</value>
</property>
</bean> <bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/conf/proxool-jdbc.properties</value>
</list>
</property>
</bean>
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" autowire="byName">
<property name="driver">
<value>${proxool.driver}</value>
</property>
<property name="driverUrl">
<value>${proxool.url}</value>
</property>
<property name="user">
<value>${proxool.username}</value>
</property>
<property name="password">
<value>${proxool.password}</value>
</property>
<property name="alias">
<value>${proxool.alias}</value>
</property>
<property name="houseKeepingSleepTime">
<value>90000</value>
</property>
</bean>
proxool-jdbc.properties proxool.driver=org.gjt.mm.mysql.Driver
proxool.username=xx
proxool.password=xx
proxool.url=jdbc:mysql://localhost:3306/xxx?useUnicode=true&characterEncoding=utf8&user=xx&password=xx
proxool.alias=xxx
<property name="houseKeepingSleepTime">
<value>90000 </value>
</property>
你退回到用proxool0.9.0RC3就没问题了
下面是他的原代码。也许你继承他的这个类再重写该方法应该可以解决。。--proxool-0.9.1
private long houseKeepingSleepTime;
private long maximumConnectionLifetime
/**
* @see ConnectionPoolDefinitionIF#getHouseKeepingSleepTime
*/
public long getHouseKeepingSleepTime() {
return houseKeepingSleepTime;
}
/**
* @see ConnectionPoolDefinitionIF#getHouseKeepingSleepTime
*/
public void setHouseKeepingSleepTime(int houseKeepingSleepTime) {
this.houseKeepingSleepTime = houseKeepingSleepTime;
}
/**
* @see ConnectionPoolDefinitionIF#getMaximumConnectionLifetime
*/
public long getMaximumConnectionLifetime() {
return maximumConnectionLifetime;
}
/**
* @see ConnectionPoolDefinitionIF#getMaximumConnectionLifetime
*/
public void setMaximumConnectionLifetime(int maximumConnectionLifetime) {
this.maximumConnectionLifetime = maximumConnectionLifetime;
}