java tomcat 6 HTTP 身份验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6998747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
tomcat 6 HTTP authentication
提问by Ryk76
I have a web app that I'm trying to deploy in Tomcat 6.0.9 on Redhat Enterprise 5.2. I was given j2ee-1.4.jar to place in the /lib directory. I found that after restarting tomcat several problems arose. But also note that removing the above jar fixes the problems listed below. I'm told I have to include j2ee-1.4.jar but I don't know what steps I need to complete to make this work.
我有一个 Web 应用程序,我正尝试在 Redhat Enterprise 5.2 上的 Tomcat 6.0.9 中部署该应用程序。我得到了 j2ee-1.4.jar 放在 /lib 目录中。我发现重启tomcat后出现了几个问题。但还要注意,删除上面的 jar 可以解决下面列出的问题。我被告知我必须包含 j2ee-1.4.jar,但我不知道我需要完成哪些步骤才能完成这项工作。
First, when attempting to login to Tomcat Manager I am no longer presented with a login dialog. It jumps right to the 401 page stating "This request requires HTTP authentication ()"
manager log for this event show the following:
此事件的经理日志显示以下内容:
org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
javax.servlet.ServletException: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:274)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:687)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:424)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:144)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:662)
Second, I noticed that the JSP example for Basic Comparisons generates this:
其次,我注意到基本比较的 JSP 示例生成了这个:
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:662)
Any help would be greatly appreciated
任何帮助将不胜感激
Thanks
谢谢
回答by BalusC
Remove that JAR file. It does notbelong in your webapp's library. It's a Glassfish specific JAR file containing an outdated Servlet API specification which would only collide with Tomcat's own JAR files. This exception is a result of a conflict in the class versions found in the classpath:
删除该 JAR 文件。它并不会在你的webapp的库属于。它是一个 Glassfish 特定的 JAR 文件,其中包含一个过时的 Servlet API 规范,该规范只会与 Tomcat 自己的 JAR 文件发生冲突。此异常是类路径中发现的类版本冲突的结果:
javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
The mentioned methodis new in Servlet 2.5 / JSP 2.1. Tomcat 6.0 is by itself a Servlet 2.5 container, but the included j2ee-1.4.jar is of a Servlet 2.4 / JSP 2.0 version.
提到的方法是 Servlet 2.5 / JSP 2.1 中的新方法。Tomcat 6.0 本身就是一个 Servlet 2.5 容器,但包含的 j2ee-1.4.jar 是一个 Servlet 2.4 / JSP 2.0 版本。
Even though when the Servlet API version of your JAR file was the same, you should never include servletcontainer-specific JAR files in your webapp's library. It would make your webapp unportable.
即使 JAR 文件的 Servlet API 版本相同,您也不应该在 web 应用程序的库中包含 servletcontainer 特定的 JAR 文件。它会使您的 web 应用程序不可移植。
If you did this to circumvent compilation errors on unresolved javax.servlet.*
classes, then you should have solved this differently. You should for example just have pointed Tomcat's own servlet-api.jar
file in the compile time classpath. E.g.
如果您这样做是为了避免未解析javax.servlet.*
类的编译错误,那么您应该以不同的方式解决这个问题。例如,您应该servlet-api.jar
在编译时类路径中指向 Tomcat 自己的文件。例如
javac -cp .;/path/to/Tomcat/lib/servlet-api.jar com/example/MyServlet.java
Or if you're using an IDE like Eclipse, you should have set the servletcontainer as Target Runtimein the project's properties. This way Eclipse will automatically take all its libraries in the project's buildpath.
或者,如果您使用的是 Eclipse 之类的 IDE,则应该在项目的属性中将 servletcontainer 设置为目标运行时。这样 Eclipse 将自动采用项目构建路径中的所有库。
See also:
也可以看看:
Once fixed that and having a clean classpath for 100% sure, then you should concentrate on solving the actual problems the proper way instead of polluting the classpath. If you stucks, just ask a new question here on Stackoverflow.
一旦解决了这个问题并且 100% 确定拥有干净的类路径,那么您应该专注于以正确的方式解决实际问题,而不是污染类路径。如果您遇到困难,请在 Stackoverflow 上提出一个新问题。
回答by saikiran
there will be duplicate entry in servlet-api.jar in your build path. remove duplicate entry or it is missing from ur buildpath. after doing this clean ur project and run
您的构建路径中的 servlet-api.jar 中将有重复条目。删除重复条目或从您的构建路径中丢失。做完这个清理你的项目并运行后