4 Replies Latest reply on Jul 16, 2007 7:45 PM by 843841

    javax.servlet.ServletException: Servlet execution threw an exception

    843841
      Hi guys...

      I got an error message after I click a button on my page. Before my action class called, servlet throw an exception.
      this is the error message from my eclipse console.
      15:31:31,062 INFO  [STDOUT] javax.servlet.ServletException: Servlet execution threw an exception
      15:31:31,062 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:275)
      15:31:31,062 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      15:31:31,156 INFO  [STDOUT]      at roll.mov.j2ee.common.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:167)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      15:31:31,156 INFO  [STDOUT]      at roll.mov.j2ee.common.filters.PersistFilter.doFilter(PersistenceFilter.java:160)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      15:31:31,156 INFO  [STDOUT]      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      15:31:31,156 INFO  [STDOUT]      at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      15:31:31,156 INFO  [STDOUT]      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      15:31:31,156 INFO  [STDOUT]      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      15:31:31,156 INFO  [STDOUT]      at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
      15:31:31,156 INFO  [STDOUT]      at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
      15:31:31,156 INFO  [STDOUT]      at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
      15:31:31,156 INFO  [STDOUT]      at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
      15:31:31,156 INFO  [STDOUT]      at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
      15:31:31,156 INFO  [STDOUT]      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      15:31:31,156 INFO  [STDOUT]      at java.lang.Thread.run(Thread.java:595)
      15:31:31,156 ERROR [PersistFilter] Exception object caught by servlet persist filter.
      15:31:31,171 ERROR [[action]] Servlet.service() for servlet action threw exception
      roll.mov.j2ee.common.exceptions.RollMovException: Error caught
      begin nested exception:
      javax.servlet.ServletException: Servlet execution threw an exception
      end nested exception:
      
      javax.servlet.ServletException: Servlet execution threw an exception
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:275)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           at roll.mov.j2ee.common.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:167)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           at roll.mov.j2ee.common.filters.PersistenceFilter.doFilter(PersistenceFilter.java:160)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
           at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
           at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
           at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
           at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
           at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
           at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
           at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
           at java.lang.Thread.run(Thread.java:595)
      
      Note:
       - roll.mov.j2ee.common.exceptions.RollMovException is my custom exception.
      - roll.mov.j2ee.common.filters.AuthenticationFilter, implement javax.servlet.Filter 
      - roll.mov.j2ee.common.filters.PersistFilter, implement javax.servlet.Filter 
      this persistFilter work as proxy hibernate filter
      From my experience, Normally the root cause will be display in the exception. but this error message doesn't provide any information about what's wrong with my code.

      Anyone have an idea?

      Thanks in advamce


      pdt
        • 1. Re: javax.servlet.ServletException: Servlet execution threw an exception
          gimbal2
          It's a bit of a strange stacktrace indeed, but without having access to the code I'd say that this line is the culprit:
          AuthenticationFilter.java:167
          • 2. Re: javax.servlet.ServletException: Servlet execution threw an exception
            843841
            Thanks for replying gimbal2.

            in that line, " AuthenticationFilter.java:167" i called the
            filterChain.doFilter(request, response);
            where filterChain is object of javax.servlet.FilterChain

            I run my jboss with debug mode and i got abit more information about the error.
            the error message:
            2006-07-20 12:56:48,437 WARN  [org.apache.struts.action.RequestProcessor] Unhandled Exception thrown: class java.lang.NullPointerException
            2006-07-20 12:56:48,437 INFO  [STDOUT] ServletException thrown
            2006-07-20 12:56:48,437 INFO  [STDOUT] javax.servlet.ServletException
            2006-07-20 12:56:48,437 INFO  [STDOUT]      at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
            2006-07-20 12:56:48,437 INFO  [STDOUT]      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
            2006-07-20 12:56:48,437 INFO  [STDOUT]      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
            2006-07-20 12:56:48,437 INFO  [STDOUT]      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
            2006-07-20 12:56:48,437 INFO  [STDOUT]      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
            2006-07-20 12:56:48,437 INFO  [STDOUT]      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            2006-07-20 12:56:48,437 INFO  [STDOUT]      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
            15:31:31,062 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:275)
            15:31:31,062 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            15:31:31,156 INFO  [STDOUT]      at roll.mov.j2ee.common.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:167)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            15:31:31,156 INFO  [STDOUT]      at roll.mov.j2ee.common.filters.PersistFilter.doFilter(PersistenceFilter.java:160)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            15:31:31,156 INFO  [STDOUT]      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            15:31:31,156 INFO  [STDOUT]      at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
            15:31:31,156 INFO  [STDOUT]      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
            15:31:31,156 INFO  [STDOUT]      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            15:31:31,156 INFO  [STDOUT]      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            15:31:31,156 INFO  [STDOUT]      at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
            15:31:31,156 INFO  [STDOUT]      at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
            15:31:31,156 INFO  [STDOUT]      at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
            15:31:31,156 INFO  [STDOUT]      at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
            15:31:31,156 INFO  [STDOUT]      at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
            15:31:31,156 INFO  [STDOUT]      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
            15:31:31,156 INFO  [STDOUT]      at java.lang.Thread.run(Thread.java:595)
            15:31:31,156 ERROR [PersistFilter] Exception object caught by servlet persist filter.
            15:31:31,171 ERROR [[action]] Servlet.service() for servlet action threw exception
            roll.mov.j2ee.common.exceptions.RollMovException: Error caught
            begin nested exception:
            javax.servlet.ServletException: Servlet execution threw an exception
            end nested exception:
             
            javax.servlet.ServletException: Servlet execution threw an exception
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:275)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at roll.mov.j2ee.common.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:167)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at roll.mov.j2ee.common.filters.PersistenceFilter.doFilter(PersistenceFilter.java:160)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                 at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                 at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
                 at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
                 at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
                 at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
                 at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
                 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
                 at java.lang.Thread.run(Thread.java:595)
            I check in docjar.com, seems like the the line in requestprocessor.java that thrown this exception is
             return (handler.execute(exception, config, mapping, form, request, response));
                 where handler is org.apache.struts.action.ExceptionHandler

            any idea guys..

            Thanks in advance


            pdt
            • 3. Re: javax.servlet.ServletException: Servlet execution threw an exception
              843841
              I'm also getting this error, but with Tomcat 5.5

              I ran 'catalina jpda run', to try and get debug mode, but nothing more
              was displayed in the stacktrace:

              Jul 16, 2007 8:07:59 AM org.apache.catalina.startup.Catalina start
              INFO: Server startup in 18357 ms
              javax.servlet.ServletException: Servlet execution threw an exception
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:275)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:173)
              at edu.msu.hc.cas.comstudentforms.filters.AuthorizationFilter.doFilter(A
              uthorizationFilter.java:191)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:173)
              at edu.msu.hc.cas.comstudentforms.filters.AuthenticationFilter.doFilter(
              AuthenticationFilter.java:242)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:173)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
              alve.java:213)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
              alve.java:178)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
              ava:126)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
              ava:105)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
              ve.java:107)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
              a:148)
              at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)

              at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
              at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
              at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.ja
              va:697)
              at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSock
              et.java:889)
              at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
              ool.java:684)
              at java.lang.Thread.run(Thread.java:595)

              the offending line in the filter servlet is:

              chain.doFilter( request, response );

              .....the servlet is the second in line, an 'AuthorizationFilter', running after
              the 'AuthenticationFilter' servlet. They are both defined in web.xml as

              <filter>
              <filter-name>Authentication Filter</filter-name>
              <filter-class>edu.msu.hc.cas.comstudentforms.filters.AuthenticationFilter</filter-class>
              <init-param>
              <description>Allows allow access to below</description>
              <param-name>excludeList</param-name>
              <param-value>login~help~logout~header~footer~js/~css/~UserFiles/Image/images/~images/</param-value>
              </init-param>
              </filter>
              <filter-mapping>
              <filter-name>Authentication Filter</filter-name>
              <url-pattern>/*</url-pattern>
              </filter-mapping>

              <filter>
              <filter-name>Authorization Filter</filter-name>
              <filter-class>edu.msu.hc.cas.comstudentforms.filters.AuthorizationFilter</filter-class>
              </filter>
              <filter-mapping>
              <filter-name>Authorization Filter</filter-name>
              <url-pattern>/*</url-pattern>
              </filter-mapping>

              .....which seems pretty straightforward.

              I'm running windows XP Pro, j2sdk 1.5.0_11-b03, and Tomcat
              v5.5.20.

              Thanks for any insights.....I'll explore more options and post anything
              I find.
              • 4. Re: javax.servlet.ServletException: Servlet execution threw an exception
                843841
                Well, I did find the solution to (my particular) error.

                The root cause was not being shown in the stack trace, so I logged
                the request object attributes and parameters with:

                catch (Exception e){
                log.error(" ---------------------------- ");
                log.error(modulename+":doFilter Exception !!");
                log.error(" msg: ["+e.getMessage()+"]");
                log.error(" request object: ");
                log.error(" attributes: ");
                Enumeration aenum = request.getAttributeNames();
                for (; aenum.hasMoreElements(); ) {
                // Get the name of the request attribute
                String hname = (String)aenum.nextElement();
                String hvalue = request.getAttribute(hname).toString();
                log.error("name: ["+hname+"]");
                log.error(" value: ["+hvalue+"]");
                }
                log.error(" parameters: ");
                aenum = request.getParameterNames();
                for (; aenum.hasMoreElements(); ) {
                // Get the name of the request paramter
                String hname = (String)aenum.nextElement();
                String hvalue = request.getParameter(hname).toString();
                log.error("name: ["+hname+"]");
                log.error(" value: ["+hvalue+"]");
                }
                log.error(" remote ip addr: ["+request.getRemoteAddr()+"]");
                log.error(" ---------------------------- ");
                e.printStackTrace();
                }

                which, of course, showed me NOTHING.

                Then I hunted around the API for something else related to the request
                object or something that would show me more.
                I discovered ServletException.

                I changed the catch block to:

                catch (ServletException e){
                log.error(" ---------------------------- ");
                log.error(modulename+":doFilter ServletException !!");
                log.error(" msg: ["+e.getMessage()+"]");
                Throwable t = e.getRootCause();
                log.error("-----------------------------");
                log.error("ROOT CAUSE:");
                log.error("-----------------------------");
                log.error(" msg: ["+t.getMessage()+"]");
                log.error(" stacktrace:");
                t.printStackTrace();
                }

                ....which showed me:

                20070716 13:54:50.982 ERROR - ----------------------------
                20070716 13:54:50.982 ERROR - comstudentforms(AuthorizationFilter):doFilter Serv
                letException !!
                20070716 13:54:50.982 ERROR - msg: [Servlet execution threw an exception]
                20070716 13:54:50.998 ERROR - -----------------------------
                20070716 13:54:50.998 ERROR - ROOT CAUSE:
                20070716 13:54:50.998 ERROR - -----------------------------
                20070716 13:54:50.998 ERROR - msg: [javax/activation/DataSource]
                20070716 13:54:50.998 ERROR - stacktrace:

                Thus showing me that activation.jar was not included with my
                app, which it should have been. No more error.

                Try the root cause logging (or use System.out.println).
                It might show the issue you're missing.