2

When i try to run project deployed inside tomcat i get error like

java.lang.NullPointerException
    at org.apache.jsp.index_jsp._jspInit(index_jsp.java:23)
    at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
    at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    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:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
    at java.lang.Thread.run(Thread.java:619)

I have searched regarding that and found that it might be problem of servlet-api.jar and jsp-api.jar but i have copied both from tomcat to my project's classpath still i am getting the same error.

Jsp :

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
     <base href="<%=basePath%>">

    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    --> 
  </head>

  <body>
    <%--<a href="login.iface">Click Here</a> --%>
  </body>
</html>

classpath contain following list of jar

antlr-2.7.6
commons-beanutils
commons-collections
commons-collections-3.1
commons-digester
commons-logging
commons-logging-1.1
dom4j-1.6.1
ejb3-persistence
hibernate3
hibernate-annotations
hibernate-commons-annotations
icefaces-1.8.2
icefaces-comps-1.8.2
javassist-3.9.0.GA
jsf-api
jsf-facelets
jsf-impl
mysql-connector-java-3.1.8-bin
slf4j-api-1.5.11
slf4j-simple-1.5.11
chetan
  • 3,175
  • 20
  • 72
  • 113
  • You haven't put those two jars into the WEB-INF/lib of your webapp, have you? If you have, then remove them. Tomcat knows those jars. It's implementing all the interfaces they contain. – JB Nizet Dec 15 '12 at 13:59
  • I have removed the same from classpath but still i am getting the same error.please check my edited question where i have mentioned the list of jar inside my classpath – chetan Dec 15 '12 at 14:34

1 Answers1

7

I have searched regarding that and found that it might be problem of servlet-api.jar and jsp-api.jar but i have copied both from tomcat to my project's classpath

It look like that you misunderstood the answers. Having them in your webapp's runtime classpath (WEB-INF/lib) is the whole cause of this problem! Get rid of them.

The servletcontainer itself already ships with those libraries out the box. Providing randomly downloaded libraries from an arbitrary container of a possibly different make/version along with the webapp would only lead to this kind of problems. If you did this in order to "fix" compilation errors in your webapp project, then you should have solved it differently. See the below links for the how:

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I have removed the same from classpath but still i am getting the same error.please check my edited question where i have mentioned the list of jar inside my classpath. – chetan Dec 15 '12 at 14:34
  • What we care about is the list of jars in the WEB-INF/lib directory of the deployed web application folder or war file. Not the classpath you use to compile the application. – JB Nizet Dec 15 '12 at 14:35
  • Indeed. See also the "See also" links for more detail. – BalusC Dec 15 '12 at 20:32
  • You helps me a lot!Thanks! – Farb Aug 12 '18 at 01:17