2
votes

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.

 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:

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

2

2 Answers

4
votes

Remove that JAR file. It does not belong 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:

javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;

The mentioned method is 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.

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.

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.

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 Runtime in the project's properties. This way Eclipse will automatically take all its libraries in the project's buildpath.

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.

0
votes

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