什么错误“The content of element type "bean" must match ”

andrew_zx 2008-10-10 11:45:50
2008-10-10 11:53:24,703 ERROR (ContextLoader.java:205) - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Line 462 in XML document from ServletContext resource [/WEB-INF/config/applicationContext-hibernate.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The content of element type "bean" must match "(description?,(constructor-arg|property|lookup-method|replaced-method)*)".
org.xml.sax.SAXParseException: The content of element type "bean" must match "(description?,(constructor-arg|property|lookup-method|replaced-method)*)".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:222)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:173)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:126)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:126)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:269)
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:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
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)
...全文
792 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
iider 2008-10-10
  • 打赏
  • 举报
回复
dao是个接口,真正放set方法的是在这个dao的实现类里
andrew_zx 2008-10-10
  • 打赏
  • 举报
回复
public interface VdnDnDAO extends DAO {
VdnDn getVdnDn(String collectonOwner);
void insertVdnDn(VdnDn vdnDn);
void updateVdnDn(VdnDn vdnDn);
void removeVdnDn(String collectionOwner);
void removeVdnDn(VdnDn vdnDn);
List findByCollectionOwner(String collectionOwner);
}

没有set方法 但是我看到别的DAO文件也没有set方法啊 也没有错误,就这个VdnDnDAO 有错误
zhj92lxs 2008-10-10
  • 打赏
  • 举报
回复
Bean property 'vdnDnDAO' is not writable or has an invalid setter method

你有set方法吗
andrew_zx 2008-10-10
  • 打赏
  • 举报
回复
我改成这样后

<bean id="vdnDnDAO" class="com.syni.im800.dao.VdnDnDAOHibernate">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>

出现这个新错误

2008-10-10 12:14:34,765 ERROR (ContextLoader.java:205) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registerFacade' defined in ServletContext resource [/WEB-INF/config/applicationContext-hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'vdnDnDAO' of bean class [com.syni.im800.facade.RegisterImpl]: Bean property 'vdnDnDAO' 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 'vdnDnDAO' of bean class [com.syni.im800.facade.RegisterImpl]: Bean property 'vdnDnDAO' 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.fact
xuhua205 2008-10-10
  • 打赏
  • 举报
回复
对,好像是说你的bean的配置语法错误,一般格式
<bean id="" class="">
<property name="" ref=""/>
.
.
.
<property name="" ref=""/>
</bean>
ee4456 2008-10-10
  • 打赏
  • 举报
回复
applicationContext-hibernate.xml,有错误,bean标签没写对?
你检查下错误,最简单的方法,就是把xml文件用浏览器打开,看看有没有语法错误...
xuhua205 2008-10-10
  • 打赏
  • 举报
回复
你用的struts几,如果是2的话,可以对对象赋值的,不需要setter方法
iider 2008-10-10
  • 打赏
  • 举报
回复
我把你的帖子从头看了一遍,应该不是vdnDnDAO这里注入sessionfactory的错

而很有可能是“registerFacade”这个bean里有个属性是vdnDnDAO,但没有set方法

最好把你整个spring配置文件贴上来,不然只能猜测。
andrew_zx 2008-10-10
  • 打赏
  • 举报
回复
我随便再里面加了一个set方法也再实现了类里返回了一个null,还是这个错误

public interface VdnDnDAO extends DAO {
VdnDn getVdnDn(String collectonOwner);
void insertVdnDn(VdnDn vdnDn);
void updateVdnDn(VdnDn vdnDn);
void removeVdnDn(String collectionOwner);
void removeVdnDn(VdnDn vdnDn);
List findByCollectionOwner(String collectionOwner);


VdnDn setVdnDn();//现在增加的
}
andrew_zx 2008-10-10
  • 打赏
  • 举报
回复
我知道 但是实现类里面也没有set方法 其他的表也是这样 都没有出错 只有这个出错

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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