0

I have a weird situation from my APP on JBoss. When I deploy my WAR onto JBoss, service availability tests will pass. But after it have went through some heavily throughput of requests, it will start to reply null pointer exceptions from my App's "return" point on some requests(~8% perhaps). Service would go back to normal if I restart the JBoss for a while until another heavily throughputs have come.

11:23:51,229 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/MyAPP].[Main]] JBWEB000236 NullPointerException
at com.Controller.Main.Signup (Main.java:211) [classes:]
...

After tracing the source code, that line number indicated to a return point at end of functiion

class Main extends BaseServlet{

    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

      String retMsg = "";
      switch(req.getParameter("Method")){
        case "signup":
            retMsg = SignUp();
      }

    }

    private String Signup(){
        
    // do signup things

        return ReturnCode.Success;// this is line 221 and where the exception is point to
    }
}

ReturnCode class

class ReturnCode{
  static final public String Success = "00";
  // other return code defines below
}

Since the server log only indicate to here with error message [classes:], I don't know why but guess if it somehow have some error like lost the ReturnCode class definition from JVM heap or what. Can anyone tell me what is it happening on here?

Using JVM: 1.8_71

user6309529
  • 153
  • 1
  • 3
  • 16
  • Please take care of java naming conventions. method names should be lower case and the oder of the modifier should be `public static final` and `static final` variablen (constants) should written in upper case – Jens Oct 07 '22 at 08:40
  • At this point you mentioned, you can not get an NPE. Use a debugger to find out what is happening – Jens Oct 07 '22 at 08:41
  • @Jens what is bothering me is why it just give me [classes:], that is really confusing. I have turn the log level to ALL but still didn't see any suspicious reason – user6309529 Oct 07 '22 at 13:19
  • I guess your class running in the container is not the class you have as source. I think you get the NPE in this line: `switch(req.getParameter("Method")){` – Jens Oct 07 '22 at 14:57
  • BTW: For the ReturnCode you should use an Enum not a class with static values – Jens Oct 07 '22 at 14:59

0 Answers0