gpt4 book ai didi

java - 由于先前的错误,Spring Web 应用程序无法启动

转载 作者:行者123 更新时间:2023-11-28 22:33:22 26 4
gpt4 key购买 nike

我正在使用 spring mvc 和 hibernate 制作一个 web 应用程序,我从 tomcat 7 控制台输出中收到一个非常奇怪的错误,指出:

13-Sep-2010 08:27:18 org.apache.catalina.startup.HostConfig checkResources INFO: Undeploying context [/ZangV3Spring] 
13-Sep-2010 08:27:18 org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive ZangV3Spring.war
13-Sep-2010 08:27:20 org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(C:\Users\xxxxx\Various stuff\apache-tomcat-7.0.0-windows-x86\apache-tomcat-7.0.0\webapps\ZangV3Spring\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
13-Sep-2010 08:27:21 org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart
13-Sep-2010 08:27:21 org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/ZangV3Spring] startup failed due to previous errors

有什么办法可以解决这个错误吗?

这是我的 build.xml:

<property name="src.dir" value="src"/>
<property name="web.dir" value="war"/>
<property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
<property name="name" value="ZangV3Spring"/>

<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<!-- We need the servlet API classes: -->
<!-- * for Tomcat 5/6 use servlet-api.jar -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
</path>

<target name="usage">
<echo message=""/>
<echo message="${name} build file"/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="build --> Build the application"/>
<echo message="deploy --> Deploy application as directory"/>
<echo message="deploywar --> Deploy application as a WAR file"/>
<echo message="install --> Install application in Tomcat"/>
<echo message="reload --> Reload application in Tomcat"/>
<echo message="start --> Start Tomcat application"/>
<echo message="stop --> Stop Tomcat application"/>
<echo message="list --> List Tomcat applications"/>
<echo message=""/>
</target>

<target name="build" description="Compile main source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>

<target name="deploy" depends="build" description="Deploy application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>

<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${deploy.path}/${name}.war"
webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>

 <path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
</fileset>
</path>

<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>

<target name="install" description="Install application in Tomcat">
<install url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"
war="${name}"/>
</target>

<target name="reload" description="Reload application in Tomcat">
<reload url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>

<target name="start" description="Start Tomcat application">
<start url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>

<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>

<target name="list" description="List Tomcat applications">
<list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>

下面是我的 build.properties 文件:

# Ant properties for building the springapp

appserver.home=C:/Users/xxxxx/Various stuff/apache-tomcat-7.0.0-windows-x86/apache-tomcat-7.0.0/
# for Tomcat 5 use $appserver.home}/server/lib
# for Tomcat 6 use $appserver.home}/lib
appserver.lib=${appserver.home}/lib/

deploy.path=${appserver.home}/webapps

tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=
tomcat.manager.password=

这是我的 lib 文件夹:

lib folder

最佳答案

如果我删除 servlett-api.jar 文件,它不会构建或编译,因为我用来引用 servlet 的任何代码都会中断。

例子是我不能再使用这个了:

import javax.servlet.http.HttpServletRequest;

this is the error im getting now [QUOTE]13-Sep-2010 12:22:45 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive ZangV3Spring.war
13-Sep-2010 12:22:49 org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
13-Sep-2010 12:22:49 org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/ZangV3Spring] startup failed due to previous errors
13-Sep-2010 12:22:49 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/ZangV3Spring] registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
13-Sep-2010 12:22:59 org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/ZangV3Spring]
13-Sep-2010 12:22:59 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive ZangV3Spring.war
13-Sep-2010 12:23:03 org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
13-Sep-2010 12:23:03 org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/ZangV3Spring] startup failed due to previous errors

this is how my web.xml looks like

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>



<!-- -->

<!-- Register and setup my servlet xml files here -->

<servlet>
<servlet-name>appStore</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
</servlet>



<servlet-mapping>
<servlet-name>appStore</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>



<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/zang-file-service.xml
</param-value>
</context-param>
</web-app>

关于java - 由于先前的错误,Spring Web 应用程序无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3698604/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com