HTTP 状态 404 - 请求的资源不可用 [英] HTTP Status 404 - The requested resource is not available

查看:168
本文介绍了HTTP 状态 404 - 请求的资源不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MyEclipse IDE 中使用 Tomcat 服务器和 Struts 2 框架时,我遇到了一个反复出现的问题.我正在将我的程序作为服务器应用程序运行,当它运行时,默认的 index.jsp 文件将成功打开,但该应用程序的其他过去都不会工作.尝试加载我的任何 .do 页面时,出现以下错误:HTTP 状态 404:请求的资源 .... 不可用.当我之前遇到这个错误时,我只是重新启动了服务器,一切都很好,但我现在没有同样的运气了.

这是我点击运行时控制台的日志.

2012 年 4 月 12 日上午 10:49:35 org.apache.catalina.core.AprLifecycleListener init信息:在 java.library.path:C:\Program Files\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_1.6.0 上找不到允许在生产环境中获得最佳性能的 Apache Tomcat Native 库.013\bin;C:\Program Files\MyEclipse\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin2012 年 4 月 12 日上午 10:49:35 org.apache.coyote.http11.Http11Protocol init信息:在 http-8080 上初始化 Coyote HTTP/1.12012 年 4 月 12 日上午 10:49:35 org.apache.catalina.startup.Catalina 加载信息:初始化在 285 毫秒内处理2012 年 4 月 12 日上午 10:49:35 org.apache.catalina.core.StandardService 开始信息:启动服务 Catalina2012 年 4 月 12 日上午 10:49:35 org.apache.catalina.core.StandardEngine 启动信息:启动 Servlet 引擎:Apache Tomcat/6.0.132012 年 4 月 12 日上午 10:49:35 org.apache.catalina.loader.WebappClassLoader validateJarFile信息:validateJarFile(C:\Documents and Settings\username\My Documents\Workspaces\.metadata\.me_tcat\webapps\project-name\WEB-INF\lib\javax.servlet-3.0.1.jar) - jar 未加载.请参阅 Servlet 规范 2.3,第 9.7.2 节.违规类:javax/servlet/Servlet.classlog4j:WARN 找不到记录器的附加程序 (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).log4j:WARN 请正确初始化 log4j 系统.2012 年 4 月 12 日上午 10:49:37 org.apache.coyote.http11.Http11Protocol start信息:在 http-8080 上启动 Coyote HTTP/1.12012 年 4 月 12 日上午 10:49:37 org.apache.jk.common.ChannelSocket init信息:JK:ajp13 监听/0.0.0.0:80092012 年 4 月 12 日上午 10:49:37 org.apache.jk.server.JkMain 开始信息:Jk 运行 ID=0 time=0/16 config=null2012 年 4 月 12 日上午 10:49:37 org.apache.catalina.startup.Catalina 开始信息:服务器在 1720 毫秒内启动

有什么建议吗?

解决方案

我认为没有任何理由在您的类路径中添加 javax.servlet-3.0.1.jar.正在使用 Eclipse 来构建/运行您的应用程序,因此当您将 tomcat 或任何服务器作为运行时环境添加到您的项目时,这些 lib 依赖项将自动添加到类路径中.简单地从您的项目的 lib 文件夹中删除此 jar.这也可能有其他原因.

  1. javax.servlet-3.0.1.jar 已添加为运行时库(在 .WAR 中)——并且仅在构建时需要它.
  2. 从 WEB-INF/lib 中删除 jar,并更新您的构建脚本以指向新位置.

<块引用>

引用的 Servlet 规范 2.3,第 9.7.2 节说 Servlet 容器(例如 Tomcat)将提供 J2EE 规范的实现类.WEB-INF/lib 目录中的 j2ee.jar(在我们的例子中是 servlet-api.jar?)试图提供相同的信息.具有特定于应用程序的实现是一个稳定性和安全性问题,这是规范 2.3 和 Tomcat 不允许的.

简而言之,从您的 lib 文件夹中删除 javax.servlet-3.0.1.jar,让容器负责为您提供这些依赖项.

要声明由容器提供的依赖项,maven 将范围设置为提供",这里是 pom.xml 中条目的外观示例:

 <依赖><groupId>javax</groupId><artifactId>javaee-web-api</artifactId><version>6.0</version><范围>提供</范围></依赖>

I'm running into a recurring problem while using the Tomcat server within the MyEclipse IDE, with the Struts 2 framework. I'm running my program as a server application and when it runs the default index.jsp file will open successfully but none of the other pasts of the application will work. When trying to load any of my my .do pages, I get the following error: HTTP Status 404: The requested resource .... is not available. When I ran into this error previously, I just restarted the server and all was fine, but I'm not having the same luck now.

Here's the log from the console when I hit run.

Apr 12, 2012 10:49:35 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\bin;C:\Program Files\MyEclipse\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin
Apr 12, 2012 10:49:35 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Apr 12, 2012 10:49:35 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 285 ms
Apr 12, 2012 10:49:35 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Apr 12, 2012 10:49:35 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.13
Apr 12, 2012 10:49:35 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Documents and Settings\username\My Documents\Workspaces\.metadata\.me_tcat\webapps\project-name\WEB-INF\lib\javax.servlet-3.0.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
log4j:WARN Please initialize the log4j system properly.
Apr 12, 2012 10:49:37 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Apr 12, 2012 10:49:37 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Apr 12, 2012 10:49:37 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16  config=null
Apr 12, 2012 10:49:37 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1720 ms

Any suggestions?

解决方案

I don't see any reason to add javax.servlet-3.0.1.jar in your class-path.Since you are using Eclipse to build/run your application, so when you will add tomcat or any server as run time env to your project these lib dependencies will automatically be added to the class-path.Simple remove this jar from the lib folder of your project. There can be other reasons also for this.

  1. javax.servlet-3.0.1.jar has been added as runtime library (in the .WAR) – and that it was only needed during build time.
  2. Remove the jar from WEB-INF/lib, and update your build script to point to the new location.

the Servlet Spec 2.3, section 9.7.2 being referred to says that the Servlet Container (E.g. Tomcat) will supply the implementation class of the J2EE spec. The j2ee.jar (servlet-api.jar in our case?) in your WEB-INF/lib directory is trying to supply the same info. Having application specific implementations is a stability and security problem that is disallowed by the spec 2.3 and by Tomcat.

In short remove the javax.servlet-3.0.1.jar from your lib folder and let the container take care of supplying these dependencies for you.

To declare a dependency which is provided by the container with maven set the scope to "provided" here is an example of how an entry in your pom.xml should look:

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

这篇关于HTTP 状态 404 - 请求的资源不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆