NoClassDefFoundError in Tomcat for Abstract Class

I have an abstract class, Problem. It’s package is com.namespace.problem. My tomcat app calls Problem.staticMethod() on each page. I get a 500 error, NoClassDefFoundError on every page. In the debugger, I can access static fields from Problem. I can successfully place breakpoints on its instance methods. It fails to place breakpoints on static methods and any static method I call causes a NoClassDefFoundError.

Tomcat is running inside a Docker container. When I run the docker container on my local machine, there are no problems. When I run it on my AWS instance, every page has a NoClassDefFoundError.

  • Docker commit without running
  • BigChainDB in Docker immediately crashes with Connection Refused?
  • Docker postgres persistance and container lifetime
  • Simulation “docker build -f” with ansible module “docker_image”
  • Confused about docker pricing policy [closed]
  • Ctrl-p and Ctrl-n behaving unexpectedly under Docker
  • I read that I should look for a ClassNotFoundException or a ExceptionInInitializerError but found nothing.

    I cannot initialize Problem (as it is abstract). I cannot see Problem.class in the debugger, it causes the error as well. I can’t instantiate any classes that extend Problem, I get the same error.

    What could be causing this? The point of docker is to be platform independent so I don’t know why this would happen on AWS but not my computer, I’m deploying the same WAR.

    Stacktrace:
        org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:574)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:461)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
        org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
        org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
        org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
        org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213)
        org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171)
        org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
        org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
        org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
    root cause
    
    javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class com.namespace.problem.Problem
        org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:909)
        org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:838)
        org.apache.jsp.view.system.index_jsp._jspService(index_jsp.java:381)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
        org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
        org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
        org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
        org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213)
        org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171)
        org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
        org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
        org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
    root cause
    
    java.lang.NoClassDefFoundError: Could not initialize class com.namespace.problem.Problem
        com.namespace.system.Application.setInitialState(Application.java:327)
        com.namespace.system.Application.setInitialState(Application.java:296)
        com.namespace.system.Application.setInitialState(Application.java:292)
        com.namespace.mvc.controller.Controller.<init>(Controller.java:80)
        com.namespace.mvc.controller.SystemController.<init>(SystemController.java:20)
        org.apache.jsp.view.system.index_jsp._jspService(index_jsp.java:122)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
        org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
        org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
        org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
        org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213)
        org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171)
        org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
        org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
        org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
    

  • List used images from Docker Compose
  • Failed to run service inside docker container
  • How can i view my dockerized container app that i just set up on Azure?
  • Why use docker? Aren't java files like WAR files already running on JVM?
  • password define for ssh connection into docker container
  • Licensing in Docker containers
  • One Solution collect form web for “NoClassDefFoundError in Tomcat for Abstract Class”

    Apparently, there was an XML config file, whose path was defined by an env var. The var on my local machine was correct, on AWS it was wrong because someone else in my repo renamed the file. Apparently, for some reason, instead of a sensible error about the file not existing, you get a NoClassDefFoundError from a class that doesn’t even use the config file.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.