大家有空帮忙看看了...求解,spring配置报的异常

yxhit 2011-05-18 04:51:51
ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testaction' defined in file [C:\Program Files\Tomcat 6.0\webapps\SearchSystem\WEB-INF\classes\beans.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 [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service': 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 [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service': no matching editors or conversion strategy found
Caused by:
java.lang.IllegalArgumentException: Cannot convert value of type [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service': 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:423)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
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:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
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:578)
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:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2011-5-18 16:46:45 org.apache.catalina.core.StandardContext listenerStart
...全文
275 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
yxhit 2011-05-18
  • 打赏
  • 举报
回复
问题解决了...
[com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service'问题出这了,我的TestService忘记实现Itest接口了,额,编程一定要小心谨慎啊....呼呼..
yxhit 2011-05-18
  • 打赏
  • 举报
回复
高手路过的来帮帮忙啊....
yxhit 2011-05-18
  • 打赏
  • 举报
回复
额....晕,又报回原来的错了,就是我贴的第一个错....
kevinPai2011 2011-05-18
  • 打赏
  • 举报
回复
解决了木有?
放牛娃的梦 2011-05-18
  • 打赏
  • 举报
回复
这个我没有看懂
yxhit 2011-05-18
  • 打赏
  • 举报
回复
我之前也是这样写的,也不报错呀,我试试吧..
wl_ldy 2011-05-18
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 wl_ldy 的回复:]

把bean.xml中的
<ref local="sessionFactory"/>
改为
<ref ref="sessionFactory"/>
其他的也都改了把local改为ref
try it...
[/Quote]
不好意思写错了
把bean.xml中的
<ref local="sessionFactory"/>
改为
<ref bean="sessionFactory"/>
其他的也都改了把local改为bean
try it...
wl_ldy 2011-05-18
  • 打赏
  • 举报
回复
把bean.xml中的
<ref local="sessionFactory"/>
改为
<ref ref="sessionFactory"/>
其他的也都改了把local改为ref
try it...
yxhit 2011-05-18
  • 打赏
  • 举报
回复
web.xml的配置:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 配置过滤器 处理中文编码格式-->
<filter>
<filter-name>filter</filter-name>
<filter-class>com.org.filters.filter</filter-class>
</filter>
<filter-mapping>
<filter-name>filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>opensession</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>flushMode</param-name>
<param-value>AUTO</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>opensession</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 配置监听器管理sping -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:bean*.xml</param-value>
</context-param>
<!-- 配置过滤器 -->
<!--<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping> -->


<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
</web-app>
wl_ldy 2011-05-18
  • 打赏
  • 举报
回复
贴配置文件web.xml bean.xml文件。。。
yxhit 2011-05-18
  • 打赏
  • 举报
回复
spring这样配置有问题吗??帮忙看看了,我改了几遍了,每改一次就报不同的异常....
<!-- 配置dao -->
<bean id="tesdao" class="com.org.dao.TestDao">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- 配置service -->
<bean id="testservice" class="com.org.service.TestService">
<property name="dao">
<ref local="testdao"/>
</property>
</bean>
<!-- 配置action -->
<bean id="testaction" class="com.org.action.TestAction">
<property name="service">
<ref local="testservice"/>
</property>
</bean>
yxhit 2011-05-18
  • 打赏
  • 举报
回复
我重新配置了一下,现在又报这个错了:
ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 88 in XML document from file [C:\Program Files\Tomcat 6.0\webapps\SearchSystem\WEB-INF\classes\beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-id.1: There is no ID/IDREF binding for IDREF 'testdao'.
Caused by:
org.xml.sax.SAXParseException: cvc-id.1: There is no ID/IDREF binding for IDREF 'testdao'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
郁闷啊....
yingzhuo2011 2011-05-18
  • 打赏
  • 举报
回复
ref <-> value

我猜,上面连个配置弄错了。
tom_66 2011-05-18
  • 打赏
  • 举报
回复
spring配置错了。service的bean配错了吧
zn85600301 2011-05-18
  • 打赏
  • 举报
回复
Cannot convert value of type [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service': no matching editors or conversion strategy found

把你的配置文件贴出来

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧