Stack Exchange
java tomcat: java.lang.NullPointerException
Hello I have a development version of a working productive webapp which gives me headache. When I login, I get following error, while admin.jsp is trying to display a folder structure. 
    org.apache.jasper.JasperException: Exception in JSP: /admin/admin.jsp:133

130:    GenDisplay display = null;
131:    if(null==oldDisplay || true==oldDisplay.checkIsOld()) {
132:        display = new GenDisplay(oldDisplay);
133:        display.genTree(((CompanySession)ppa).getRootOrdner(), ((CompanySession)ppa).getRootType(), user.getUID(), out);
134:        ((CompanySession)ppa).setGenDisplay(display);   
135:    } else {
136:        display = oldDisplay;


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

java.lang.NullPointerException
    ppa.admin.GenDisplay.getKey(GenDisplay.java:185)
    ppa.admin.GenDisplay.isOpen(GenDisplay.java:161)
    ppa.admin.GenDisplay.genSubTree(GenDisplay.java:49)
    ppa.admin.GenDisplay.genSubTree(GenDisplay.java:57)
    ppa.admin.GenDisplay.genSubTree(GenDisplay.java:57)
    ppa.admin.GenDisplay.genSubTree(GenDisplay.java:57)
    ppa.admin.GenDisplay.genTree(GenDisplay.java:42)
    org.apache.jsp.admin.admin_jsp._jspService(admin_jsp.java:606)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

This is the admin_jsp.java around line 606 codeblock to generate the error:
GenDisplay oldDisplay = ((CompanySession)ppa).getGenDisplay();
    GenDisplay display = null;
    if(null==oldDisplay || true==oldDisplay.checkIsOld()) {
        display = new GenDisplay(oldDisplay);
        display.genTree(((CompanySession)ppa).getRootOrdner(), ((CompanySession)ppa).getRootType(), user.getUID(), out);
        ((CompanySession)ppa).setGenDisplay(display);   
    } else {
        display = oldDisplay;
    }
    //out.println(((CompanySession)ppa).getRootOrdner());
    //
    int currentOrdner = ((CompanySession)ppa).getRootOrdner();
    int currentOrdnerType = ((CompanySession)ppa).getRootType();
    if(null!=oldDisplay) {
    currentOrdner = oldDisplay.getCurrentOrdner();
    currentOrdnerType = oldDisplay.getCurrentOrdnerType();
    } else {
        display.openOrdner(((CompanySession)ppa).getRootOrdner(), ((CompanySession)ppa).getRootType());
}

So I sorted one of the variable passed to display.genTree() is null, that's why the NullPointerException. This development is exactly copied from the working production version, why throwing an error here and not on the production version? I'm puzzled. Does anybody has idea? Thanks in advance!
p.s.: I compared java version, tomcat version, compiler version. I reestablished same settings for both tomcats. I compared mysql server versions and settings. They are almost the same versions and settings. No major release difference with the software involved. I tried newer versions of tomcat (6,7) and got different errors, so this confused me even more. I really need help, since I didn't wrote the webapp and I am new to java.

We have no idea what's null, no idea what the code is actually doing, pretty much nothing to go on.

Clearly, something is different between your development and production servers.  That's about as much as it's possible to say, given that we don't have access to either.

Is tomcat version same for development  & production

Folder structure of what, anyway?

Sorry you guys, i wasn't responding at all for a long time. I have to change the mail preferences to alert me when questions/posts are given to my questions. In the meantime i found out what the problem was. It had nothing to do with the actual code here. mcfinnigan was as closest as possible of all, although it was still far away from a good hint. This was no critic at all. I'm more than thankful to see people concerned with my Problem. It had something to do with attribution of element types in the system which I interferred with my code changes. Thanks again for helping!

The issue is not withing the generated servlet code. The NPE occurs in  ppa.admin.GenDisplay.getKey(GenDisplay.java:185) a variable (null) is dereferenced, so you need to look what happens in line 185 and find out where the variable should have been set.
Tracing this back will show the difference (something like: environment variables or file system permissions) of dev and production.
