Search code examples
javaangularweblogicinternal-server-errorhttp-error

how to display stack trace instead of 500 internal server error on weblogic


I was working with tomcat 7 and when an exception is thrown the stack trace is shown in the browser. But now I'm using WebLogic 12 . Occasionally, I'll get the message "Error 500--Internal Server Error" appear in my web browser when something has gone wrong and I have to look in the log files for the stack trace of the exception. How can I get the exception to be output directly to my browser ?

FrontEnd Angular. BackEnd Java.


Solution

  • The solution is to configure a http filter and intercept the exception then send the message to the frontEnd. In prod mode we cant show stack trace.

    in web.xml file we add this:

     <filter>
         <filter-name>msg</filter-name>
         <filter-class>com.filters.MSGFilter</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>msg</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>