问题描述
2011-11-28 14:36:49 org.apache.catalina.core.AprLifecycleListener init信息: Loaded APR based Apache Tomcat Native library 1.1.20.2011-11-28 14:36:49 org.apache.catalina.core.AprLifecycleListener init信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].2011-11-28 14:36:49 org.apache.coyote.http11.Http11AprProtocol init信息: Initializing Coyote HTTP/1.1 on http-80802011-11-28 14:36:49 org.apache.coyote.ajp.AjpAprProtocol init信息: Initializing Coyote AJP/1.3 on ajp-80092011-11-28 14:36:49 org.apache.catalina.startup.Catalina load信息: Initialization processed in 706 ms2011-11-28 14:36:49 org.apache.catalina.core.StandardService start信息: Starting service Catalina2011-11-28 14:36:49 org.apache.catalina.core.StandardEngine start信息: Starting Servlet Engine: Apache Tomcat/6.0.302011-11-28 14:36:49 org.apache.catalina.startup.HostConfig deployDescriptor信息: Deploying configuration descriptor host-manager.xml2011-11-28 14:36:50 org.apache.catalina.startup.HostConfig deployDescriptor信息: Deploying configuration descriptor manager.xml2011-11-28 14:36:50 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory 1112011-11-28 14:36:50 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory blog2011-11-28 14:36:50 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory bookstore2011-11-28 14:36:50 org.apache.catalina.loader.WebappClassLoader validateJarFile信息: validateJarFile(D:Tomcat 6.0webappsbookstoreWEB-INFlibservlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.classlog4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).log4j:WARN Please initialize the log4j system properly.2011-11-28 14:36:50 org.apache.catalina.core.ApplicationContext log信息: Loading Spring root WebApplicationContext2011-11-28 14:36:51 org.apache.catalina.core.StandardContext listenerStart严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 7 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Element type "session-factory" must be declared.Caused by: org.xml.sax.SAXParseException: Element type "session-factory" must be declared.at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1929)at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:764)at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1359)at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2747)at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:225)at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:351)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:123)at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:91)at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)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:4172)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4671)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)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:142)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)at org.apache.catalina.core.StandardService.start(StandardService.java:525)at org.apache.catalina.core.StandardServer.start(StandardServer.java:701)at org.apache.catalina.startup.Catalina.start(Catalina.java:585)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)2011-11-28 14:36:51 org.apache.catalina.core.StandardContext start严重: Error listenerStart2011-11-28 14:36:51 org.apache.catalina.core.StandardContext start严重: Context [/bookstore] startup failed due to previous errors2011-11-28 14:36:51 org.apache.catalina.core.ApplicationContext log信息: Closing Spring root WebApplicationContext2011-11-28 14:36:51 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory bookstore12011-11-28 14:36:51 org.apache.catalina.loader.WebappClassLoader validateJarFile信息: validateJarFile(D:Tomcat 6.0webappsbookstore1WEB-INFlibservlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.classlog4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).log4j:WARN Please initialize the log4j system properly.2011-11-28 14:36:51 org.apache.catalina.core.ApplicationContext log信息: Loading Spring root WebApplicationContext2011-11-28 14:36:53 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory docs2011-11-28 14:36:53 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory examples2011-11-28 14:36:53 org.apache.catalina.core.ApplicationContext log信息: ContextListener: contextInitialized()2011-11-28 14:36:53 org.apache.catalina.core.ApplicationContext log信息: SessionListener: contextInitialized()2011-11-28 14:36:53 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory ROOT2011-11-28 14:36:53 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory struts2Ex2011-11-28 14:36:54 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register信息: Parsing configuration file [struts-default.xml]2011-11-28 14:36:54 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register信息: Parsing configuration file [struts-plugin.xml]2011-11-28 14:36:54 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register信息: Parsing configuration file [struts.xml]2011-11-28 14:36:54 org.apache.struts2.config.Settings getLocale警告: Settings: Could not parse struts.locale setting, substituting default VM locale2011-11-28 14:36:54 org.apache.struts2.config.BeanSelectionProvider register信息: Loading global messages from message2011-11-28 14:36:54 com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory <clinit>信息: Setting DefaultObjectTypeDeterminer as default ...2011-11-28 14:36:54 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory test2011-11-28 14:36:54 org.apache.catalina.loader.WebappClassLoader validateJarFile信息: validateJarFile(D:Tomcat 6.0webappstestWEB-INFlibservlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.classlog4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).log4j:WARN Please initialize the log4j system properly.2011-11-28 14:36:55 org.apache.catalina.core.ApplicationContext log信息: Loading Spring root WebApplicationContext2011-11-28 14:36:55 org.apache.catalina.core.StandardContext listenerStart严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/classes/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/classes/applicationContext.xml]Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/classes/applicationContext.xml]at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:99)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:297)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:123)at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:91)at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)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:4172)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4671)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)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:142)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)at org.apache.catalina.core.StandardService.start(StandardService.java:525)at org.apache.catalina.core.StandardServer.start(StandardServer.java:701)at org.apache.catalina.startup.Catalina.start(Catalina.java:585)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)2011-11-28 14:36:55 org.apache.catalina.core.StandardContext start严重: Error listenerStart2011-11-28 14:36:55 org.apache.catalina.core.StandardContext start严重: Context [/test] startup failed due to previous errors2011-11-28 14:36:55 org.apache.catalina.core.ApplicationContext log信息: Closing Spring root WebApplicationContext2011-11-28 14:36:55 org.apache.coyote.http11.Http11AprProtocol start信息: Starting Coyote HTTP/1.1 on http-80802011-11-28 14:36:55 org.apache.coyote.ajp.AjpAprProtocol start信息: Starting Coyote AJP/1.3 on ajp-80092011-11-28 14:36:55 org.apache.catalina.startup.Catalina start信息: Server startup in 5689 msapplicationContext.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:p="http://www.springframework.org/schema/p"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.mysql.jdbc.Driver"></property><property name="url" value="jdbc:mysql://localhost:3306/user"></property><property name="username" value="root"></property><property name="password" value="123456"></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.MySQLDialect</prop></props></property><property name="mappingResources"><list><value>./User.hbm.xml</value></list></property></bean><bean id="login" class="LoginAction"><property name="sessionFactory"><ref bean="sessionFactory" /></property></bean></beans>
解决方案
找不到applicationContext.xml,应该是这个路径弄错了
解决方案二:
用src的绝对路径 比如放在src文件夹下的com.user包下 路径就是<value>com/user/User.hbm.xml</value>
解决方案三:
是不是路径配错了引用<property name="mappingResources"> <list> <value>./User.hbm.xml</value> </list> </property>