I am getting a strange exception when running my java web project. It appears such as this 'randomly' happened once i saved some changes to 1 of my JSPs. I do not ever remember altering around any configurations. I have never encounter any errors such as this before out of this project, it's didn't have problem locating the HubPortal class before.

Here's the entire stack trace:

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

4: %>
5: <%
6: String responsepage = request.getParameter("show");
7: HubPortal hp = new HubPortal();
8: List processList = hp.getProcessList();
9: List clientList = hp.getClientList();
10: List transList = hp.getTransactionTypeList();


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:412)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
    org.apache.jsp.hubmainpage_jsp._jspService(hubmainpage_jsp.java:783)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    com.middleware.hts.HubPortal.<clinit>(HubPortal.java:23)
    org.apache.jsp.hubmainpage_jsp._jspService(hubmainpage_jsp.java:66)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Any ideas why I am out of the blue experiencing this error?

Additionally to everyones answer I wish to say some strategies for java.lang.NoClassDefFoundError or java.lang.ClassNotFoundException:

  1. You need to first confirm your classpath
  2. You have to make sure the needed classes under %CONTEXT-ROOT%/WEB-INF/Classes(Servlet directory) or When the dependent classes availble for you as JAR then it's inside %CONTEXT-ROOT%/WEB-INF/lib/xyz.jar. Recall the container must access these classes throughout runtime!
7: HubPortal hp = new HubPortal();

root cause 

java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    com.middleware.hts.HubPortal.<clinit>(HubPortal.java:23)

Which means that the log4j jar file is missing in webapp's runtime classpath even though it is been needed through the HubPortal class. You have to place it in the same location because the JAR file that contains the HubPortal class, for instance the /WEB-INF/lib folder or wherever else the HubPortal class is.

Appears like your HubPortal class can't discover the Logger class, make that available in your web-inf.

The reason being you are not implementing the log4j jar. This ought to be a part of your war, in WEB-INF/lib.