您的位置:程序门 -> java ->



struts + spring + hibernate 问题!!!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


struts + spring + hibernate 问题!!![无满意答案结贴,结贴人:catastiger]
发表于:2007-11-16 14:46:38 楼主
近来做一个struts   +spring   +   hibernate   的web小程序时出现以下错误:
我加载顺序是spring   ,hiberante,struts
请高手指点一下小弟:具体原因是什么?为什么会这样?
2007-11-16   14:38:20,703   error   [org.apache.catalina.core.containerbase.[catalina].[localhost].[/sshtest3]]   -   action:   null
org.springframework.beans.factory.beandefinitionstoreexception:   line   5   in   xml   document   from   servletcontext   resource   [/web-inf/applicationcontext.xml]   is   invalid;   nested   exception   is   org.xml.sax.saxparseexception:   document   root   element   "beans ",   must   match   doctype   root   "null ".
org.xml.sax.saxparseexception:   document   root   element   "beans ",   must   match   doctype   root   "null ".
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.rootelementspecified(unknown   source)
at   org.apache.xerces.impl.dtd.xmldtdvalidator.handlestartelement(unknown   source)
at   org.apache.xerces.impl.dtd.xmldtdvalidator.startelement(unknown   source)
at   org.apache.xerces.impl.xmldocumentfragmentscannerimpl.scanstartelement(unknown   source)
at   org.apache.xerces.impl.xmldocumentscannerimpl$contentdispatcher.scanrootelementhook(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   javax.xml.parsers.documentbuilder.parse(documentbuilder.java:98)
at   org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:161)
at   org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:125)
at   org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:141)
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:268)
at   org.springframework.web.context.support.abstractrefreshablewebapplicationcontext.refresh(abstractrefreshablewebapplicationcontext.java:134)
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:869)
at   org.apache.struts.action.actionservlet.init(actionservlet.java:336)
at   javax.servlet.genericservlet.init(genericservlet.java:211)
at   org.apache.catalina.core.standardwrapper.loadservlet(standardwrapper.java:1091)
at   org.apache.catalina.core.standardwrapper.load(standardwrapper.java:925)
at   org.apache.catalina.core.standardcontext.loadonstartup(standardcontext.java:3857)
at   org.apache.catalina.core.standardcontext.start(standardcontext.java:4118)
at   org.apache.catalina.core.containerbase.addchildinternal(containerbase.java:759)
at   org.apache.catalina.core.containerbase.addchild(containerbase.java:739)
at   org.apache.catalina.core.standardhost.addchild(standardhost.java:524)
at   org.apache.catalina.startup.hostconfig.deploydirectory(hostconfig.java:894)
at   org.apache.catalina.startup.hostconfig.deploydirectories(hostconfig.java:857)
at   org.apache.catalina.startup.hostconfig.deployapps(hostconfig.java:475)
at   org.apache.catalina.startup.hostconfig.start(hostconfig.java:1102)
at   org.apache.catalina.startup.hostconfig.lifecycleevent(hostconfig.java:311)
at   org.apache.catalina.util.lifecyclesupport.firelifecycleevent(lifecyclesupport.java:119)
at   org.apache.catalina.core.containerbase.start(containerbase.java:1020)
at   org.apache.catalina.core.standardhost.start(standardhost.java:718)
at   org.apache.catalina.core.containerbase.start(containerbase.java:1012)
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:683)
at   org.apache.catalina.startup.catalina.start(catalina.java:537)
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:585)
at   org.apache.catalina.startup.bootstrap.start(bootstrap.java:271)
at   org.apache.catalina.startup.bootstrap.main(bootstrap.java:409)
发表于:2007-11-16 14:47:071楼 得分:0
2007-11-16   14:38:20,718   info   [org.apache.catalina.core.containerbase.[catalina].[localhost].[/sshtest3]]   -   marking   servlet   action   as   unavailable
2007-11-16   14:38:20,718   error   [org.apache.catalina.core.containerbase.[catalina].[localhost].[/sshtest3]]   -   servlet   /sshtest3   threw   load()   exception
javax.servlet.unavailableexception
at   org.apache.struts.action.actionservlet.initmoduleplugins(actionservlet.java:880)
at   org.apache.struts.action.actionservlet.init(actionservlet.java:336)
at   javax.servlet.genericservlet.init(genericservlet.java:211)
at   org.apache.catalina.core.standardwrapper.loadservlet(standardwrapper.java:1091)
at   org.apache.catalina.core.standardwrapper.load(standardwrapper.java:925)
at   org.apache.catalina.core.standardcontext.loadonstartup(standardcontext.java:3857)
at   org.apache.catalina.core.standardcontext.start(standardcontext.java:4118)
at   org.apache.catalina.core.containerbase.addchildinternal(containerbase.java:759)
at   org.apache.catalina.core.containerbase.addchild(containerbase.java:739)
at   org.apache.catalina.core.standardhost.addchild(standardhost.java:524)
at   org.apache.catalina.startup.hostconfig.deploydirectory(hostconfig.java:894)
at   org.apache.catalina.startup.hostconfig.deploydirectories(hostconfig.java:857)
at   org.apache.catalina.startup.hostconfig.deployapps(hostconfig.java:475)
at   org.apache.catalina.startup.hostconfig.start(hostconfig.java:1102)
at   org.apache.catalina.startup.hostconfig.lifecycleevent(hostconfig.java:311)
at   org.apache.catalina.util.lifecyclesupport.firelifecycleevent(lifecyclesupport.java:119)
at   org.apache.catalina.core.containerbase.start(containerbase.java:1020)
at   org.apache.catalina.core.standardhost.start(standardhost.java:718)
at   org.apache.catalina.core.containerbase.start(containerbase.java:1012)
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:683)
at   org.apache.catalina.startup.catalina.start(catalina.java:537)
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:585)
at   org.apache.catalina.startup.bootstrap.start(bootstrap.java:271)
at   org.apache.catalina.startup.bootstrap.main(bootstrap.java:409)
2007-11-16   14:38:20   org.apache.coyote.http11.http11protocol   start
发表于:2007-11-16 14:50:082楼 得分:0
applicationcontext.xml代码贴上来看看!
发表于:2007-11-16 15:02:053楼 得分:0
<?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.0.xsd">


<bean   id="datasource"
class="org.apache.commons.dbcp.basicdatasource">
<property   name="driverclassname"
value="com.microsoft.jdbc.sqlserver.sqlserverdriver">
</property>
<property   name="url"
value="jdbc:microsoft:sqlserver://localhost:1433;databasename=pubs">
</property>
<property   name="username"   value="sa"> </property>
<property   name="password"   value="1"> </property>
</bean>
<bean   id="sessionfactory"
class="org.springframework.orm.hibernate3.localsessionfactorybean">
<property   name="datasource">
<ref   bean="datasource"   />
</property>
<property   name="hibernateproperties">
<props>
<prop   key="hibernate.dialect">
org.hibernate.dialect.sqlserverdialect
</prop>
</props>
</property>
<property   name="mappingresources">
<list>
<value> com/sunray/sshtest3/pojo/users.hbm.xml </value> </list>
</property> </bean>
<bean   id="usersdao"   class="com.sunray.sshtest3.pojo.usersdao">
<property   name="sessionfactory">
<ref   bean="sessionfactory"   />
</property>
</bean>
<bean   id="services"   class="com.sunray.sshtest3.module.impl.userimpl">
<property   name="dao">
<ref   bean="usersdao"/>
</property>
</bean>
<bean   name="/user"   class="com.sunray.sshtest3.struts.action.useraction">
<property   name="iu">
<ref   bean="services"/>
</property>
</bean> </beans>
发表于:2007-11-16 15:22:404楼 得分:0
<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.0.xsd   ">  

改为:

<!doctype   beans   public   "-//spring//dtd   bean//en"   "http://www.springframework.org/dtd/spring-beans.dtd">
发表于:2007-11-16 15:24:225楼 得分:0
4楼的兄弟,我试过了,那样不行!
发表于:2007-11-17 16:13:136楼 得分:0
dtd写错了吧
document       root       element       "beans   ",       must       match       doctype       root       "null   ".  
发表于:2007-11-17 16:31:137楼 得分:0
哈哈!格式有问题!
发表于:2007-11-23 15:28:348楼 得分:0
格式有什么问题?我用的是spring   2.0,
<?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/aop   http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
              http://www.springframework.org/schema/tx   http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
>
同样报错,请教是什么地方错了?
发表于:2007-11-23 15:34:099楼 得分:0
网上提示的答案一般是spring的jar包的问题,但是,我的jar包版本是对的啊,spring   2.0的包啊,有高手知道有其它原因吗?


快速检索

最新资讯
热门点击