I've been focusing on a work for 6 several weeks using internet beans ide to be able to develop an elearning web application.Everything labored fine inside internet beans.(The project was from existing sources and that i needed to modify it,i did not develop the whole application)I had been using apache tomcat 7 in internet beans.After i produced the war file and used it nothing labored.I get null pointer exceptions during my session variables like i never provide them with something.I'm not in a position to understand what is the problem.Inside internet beans i'm utilizing the same tomcat.

    org.apache.jasper.JasperException: An exception occurred processing JSP page /System.jsp at line 31

28:       Integer intObj = new Integer(project_id);
29:       httpsession.setAttribute("project_id",intObj);
30:       Hashtable projects=(Hashtable)session.getAttribute("projectsprofessor");
31:       if((Integer)session.getAttribute("professor")<=1 &&
32:           projects.get(project_id)==null)
33:                    {
34:           request.getSession().setAttribute("errorMessage","This project belongs to another professor!");


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

java.lang.NullPointerException
    org.apache.jsp.System_jsp._jspService(System_jsp.java:149)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

This occurs towards the the majority of my pages.The strange is the fact that some session variables aren't null. I am unable to understand where you can focus!

thanks.

//Edit:Solved!The issue was that Within the sources i acquired they've didn't remember *.class files in WEB-INF folder then when i clean-and-build in NetBeans the brand new classes did not compile and internet beans used the prior sources on the internet-INF folder.After i erased by hand all of the .class files from WEB-INF/Classes within the next clean-build used the brand new files

org.apache.jasper.JasperException: The best happened processing JSP page /System.jsp at line 31

Line 31 is thus the next:

if((Integer)session.getAttribute("professor")<=1 && ...

A NPE here can technically only have 2 causes:

  1. The session is null and getAttribute() will fail with NPE.
  2. The attribute "professor" came back null and also the int autoboxing for <= will fail with NPE.

The very first cause is not likely as line 30 would certainly have unsuccessful first. I'll wager it's the second cause. You have to check first when the attribute isn't null.

Integer professor = session.getAttribute("professor");
if ((professor == null || professor <= 1) && ...

Possibly you have to solve it at greater level, i.e. make certain the "professor" attribtue is never null.


Unrelated towards the concrete problem, Java code goes in Java classes. Every time they visit debugging, testing and maintainance and the like much simpler.