问题描述
2010-9-8 0:20:42 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:Program FilesJavajdk1.6.0_10bin;D:apache-tomcat-6.0.24apache-tomcat-6.0.24bin 2010-9-8 0:20:42 org.apache.coyote.http11.Http11Protocol init 信息: Initializing Coyote HTTP/1.1 on http-8080 2010-9-8 0:20:42 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 639 ms 2010-9-8 0:20:42 org.apache.catalina.core.StandardService start 信息: Starting service Catalina 2010-9-8 0:20:42 org.apache.catalina.core.StandardEngine start 信息: Starting Servlet Engine: Apache Tomcat/6.0.24 2010-9-8 0:20:42 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory epet log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources). log4j:WARN Please initialize the log4j system properly. 2010-9-8 0:20:45 org.apache.catalina.core.ApplicationContext log 信息: Initializing WebApplicationContext for Struts ActionServlet 'action', module '' 2010-9-8 0:20:54 org.apache.catalina.core.ApplicationContext log 严重: action: null org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/petDiary' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [epet.biz.impl.PetInfoBizImpl] to required type [epet.biz.PetDiaryBiz] for property 'biz'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [epet.biz.impl.PetInfoBizImpl] to required type [epet.biz.PetDiaryBiz] for property 'biz': no matching editors or conversion strategy found Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [epet.biz.impl.PetInfoBizImpl] to required type [epet.biz.PetDiaryBiz] for property 'biz'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [epet.biz.impl.PetInfoBizImpl] to required type [epet.biz.PetDiaryBiz] for property 'biz': no matching editors or conversion strategy found Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [epet.biz.impl.PetInfoBizImpl] to required type [epet.biz.PetDiaryBiz] for property 'biz': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:815) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1127) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.web.struts.ContextLoaderPlugIn.createWebApplicationContext(ContextLoaderPlugIn.java:355) at org.springframework.web.struts.ContextLoaderPlugIn.initWebApplicationContext(ContextLoaderPlugIn.java:296) at org.springframework.web.struts.ContextLoaderPlugIn.init(ContextLoaderPlugIn.java:225) at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1158) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4496) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:722) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:593) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 2010-9-8 0:20:54 org.apache.catalina.core.ApplicationContext log 信息: Marking servlet action as unavailable 2010-9-8 0:20:54 org.apache.catalina.core.StandardContext loadOnStartup 严重: Servlet /epet threw load() exception javax.servlet.UnavailableException at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1169) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4496) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:722) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:593) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 2010-9-8 0:20:54 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory epet.myeclipse.bak log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources). log4j:WARN Please initialize the log4j system properly. 2010-9-8 0:20:56 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory hourse log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources). log4j:WARN Please initialize the log4j system properly. 2010-9-8 0:20:59 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on http-8080 2010-9-8 0:20:59 org.apache.jk.common.ChannelSocket init 信息: JK: ajp13 listening on /0.0.0.0:8009 2010-9-8 0:20:59 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=0/47 config=null 2010-9-8 0:20:59 org.apache.catalina.startup.Catalina start 信息: Server startup in 17017 ms 下面是我的applicationContext.xml文件内容<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/> <property name="url" value="jdbc:sqlserver://localhost:1433;DataBaseName=epet;SelectMethod=cursor"></property> <property name="username" value="sa"></property> <property name="password" value="123456"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource"/> </property> <property name="mappingResources"> <list> <value>epet/entity/PetInfo.hbm.xml</value> <value>epet/entity/PetDiary.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.SQLServerDialect </prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="petInfoDAO" class="epet.dao.hibimpl.PetInfoDAOHiblImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="petDiaryDAO" class="epet.dao.hibimpl.PetDiaryDAOHibImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="petInfoBiz" class="epet.biz.impl.PetInfoBizImpl"> <property name="biz" ref="petInfoDAO"></property> </bean> <bean id="petDiaryBiz" class="epet.biz.impl.PetDiaryBIzImpl"> <property name="biz" ref="petDiaryDAO"></property> </bean> <bean name="/pet" class="epet.web.action.PetAction"> <property name="biz" ref="petInfoBiz"></property> </bean> <bean name="/petDiary" class="epet.web.action.PetDiaryAction"> <property name="biz" ref="petInfoBiz"></property> </bean> <bean id="myHibTxManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:advice id="txAdvice" transaction-manager="myHibTxManager"> <tx:attributes> <tx:method name="get*" propagation="SUPPORTS" read-only="true"/> <tx:method name="load*" propagation="SUPPORTS" read-only="true"/> <tx:method name="search*" propagation="SUPPORTS" read-only="true"/> <tx:method name="to*" propagation="SUPPORTS" read-only="true"/> <tx:method name="do*" propagation="REQUIRED"/> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="bizMethod" expression="execution(* epet.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethod"/> </aop:config></beans> 问题补充:<div class="quote_title">pxb1988 写道</div><div class="quote_div">请检查epet.web.action.PetAction,epet.web.action.PetDiaryAction类中的biz属性的类型,安照你的配置文件他们都应该是epet.biz.impl.PetInfoBiz类型的,<br />重点检查/petDiary对应的epet.web.action.PetDiaryAction<br /><div class="quote_title">引用</div><div class="quote_div"><br /> <bean name="/pet" class="epet.web.action.PetAction"><br /> <property name="biz" ref="petInfoBiz"></property><br /> </bean><br /> <bean name="/petDiary" class="epet.web.action.PetDiaryAction"><br /> <property name="biz" ref="petInfoBiz"></property><br /> </bean><br /></div><br />其中类<br /><div class="quote_title">引用</div><div class="quote_div">org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/petDiary' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception i</div></div><br />
解决方案
请检查epet.web.action.PetAction,epet.web.action.PetDiaryAction类中的biz属性的类型,安照你的配置文件他们都应该是epet.biz.impl.PetInfoBiz类型的,重点检查/petDiary对应的epet.web.action.PetDiaryAction引用 <bean name="/pet" class="epet.web.action.PetAction"> <property name="biz" ref="petInfoBiz"></property> </bean> <bean name="/petDiary" class="epet.web.action.PetDiaryAction"> <property name="biz" ref="petInfoBiz"></property> </bean>其中类引用org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/petDiary' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception i
解决方案二:
引用 <bean name="/pet" class="epet.web.action.PetAction"> <property name="biz" ref="petInfoBiz"></property> </bean> <bean name="/petDiary" class="epet.web.action.PetDiaryAction"> <property name="biz" ref="petInfoBiz"></property> </bean>你这是配置的action吗???没怎么见过,你可以不用这么配,配置到dao就行了,在struts里用构造函数来初始化bean,这样可以