Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-24696

GroovyHookScript needs Jenkins.getInstance() but should not (called for HudsonFailedToLoad)

    Details

    • Similar Issues:

      Description

      Reports on the mailing list that look like this:

      Jul 03, 2014 6:56:03 PM org.apache.catalina.core.StandardContext listenerStart
      SEVERE: Exception sending context initialized event to listener instance of class hudson.WebAppMain
      java.lang.NullPointerException
              at jenkins.util.groovy.GroovyHookScript.run(GroovyHookScript.java:63)
              at hudson.util.BootFailure.publish(BootFailure.java:43)
              at hudson.WebAppMain.contextInitialized(WebAppMain.java:244)
              at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
              at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
              at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1258)
              at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:716)
              at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:221)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
              at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
              at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
              at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:611)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
              at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
              at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
              at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
              at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
              at java.lang.Thread.run(Thread.java:722) 
      

      So it seems broken for all boot-failure messages.

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            If BootFailure is being run, obviously something broke during boot, so why are we running code that blithely assumes Jenkins.getInstance() is non-null (and servletContext valid) without doing a null check?

            And why are we even using Jenkins.getInstance().servletContext? BootFailure.publish already has a ServletContext! It should just pass it to the GroovyHookScript.

            High priority IMO since when this happens, it means there was a fatal error that blocked Jenkins from starting…but that error is completely lost because this NPE is printed instead.

            I would suggest that LOGGER.log(SEVERE, "Failed to initialize Jenkins",e); be run even in case of BootFailure, just to be sure that the root cause is never lost.

            Show
            jglick Jesse Glick added a comment - If BootFailure is being run, obviously something broke during boot, so why are we running code that blithely assumes Jenkins.getInstance() is non-null (and servletContext valid) without doing a null check? And why are we even using Jenkins.getInstance().servletContext ? BootFailure.publish already has a ServletContext ! It should just pass it to the GroovyHookScript . High priority IMO since when this happens, it means there was a fatal error that blocked Jenkins from starting…but that error is completely lost because this NPE is printed instead. I would suggest that LOGGER.log(SEVERE, "Failed to initialize Jenkins",e); be run even in case of BootFailure , just to be sure that the root cause is never lost.
            Hide
            jglick Jesse Glick added a comment -

            Disregard the last two paragraphs—I failed to notice that the original stack trace is already reported with Failed to initialize Jenkins.

            Show
            jglick Jesse Glick added a comment - Disregard the last two paragraphs—I failed to notice that the original stack trace is already reported with Failed to initialize Jenkins .
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            core/src/main/java/hudson/init/impl/GroovyInitScript.java
            core/src/main/java/hudson/util/BootFailure.java
            core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
            test/src/test/java/hudson/util/BootFailureTest.java
            http://jenkins-ci.org/commit/jenkins/42de07bba60bdde51ee7123ed6c65a11cddb78ae
            Log:
            [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null when we are running a boot failure script.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/init/impl/GroovyInitScript.java core/src/main/java/hudson/util/BootFailure.java core/src/main/java/jenkins/util/groovy/GroovyHookScript.java test/src/test/java/hudson/util/BootFailureTest.java http://jenkins-ci.org/commit/jenkins/42de07bba60bdde51ee7123ed6c65a11cddb78ae Log: [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null when we are running a boot failure script.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            core/src/main/java/hudson/WebAppMain.java
            core/src/main/java/hudson/init/impl/GroovyInitScript.java
            core/src/main/java/hudson/util/BootFailure.java
            core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
            test/src/test/groovy/hudson/util/BootFailureTest.groovy
            test/src/test/java/hudson/util/BootFailureTest.java
            http://jenkins-ci.org/commit/jenkins/8cfa1e890f598edfb911d5c9591cd2109b4ad509
            Log:
            Merge pull request #1950 from jglick/WebAppMain.contextDestroyed-logging

            JENKINS-24696 WebAppMain.contextDestroyed produces weird errors

            Compare: https://github.com/jenkinsci/jenkins/compare/dda00aa62300...8cfa1e890f59

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/WebAppMain.java core/src/main/java/hudson/init/impl/GroovyInitScript.java core/src/main/java/hudson/util/BootFailure.java core/src/main/java/jenkins/util/groovy/GroovyHookScript.java test/src/test/groovy/hudson/util/BootFailureTest.groovy test/src/test/java/hudson/util/BootFailureTest.java http://jenkins-ci.org/commit/jenkins/8cfa1e890f598edfb911d5c9591cd2109b4ad509 Log: Merge pull request #1950 from jglick/WebAppMain.contextDestroyed-logging JENKINS-24696 WebAppMain.contextDestroyed produces weird errors Compare: https://github.com/jenkinsci/jenkins/compare/dda00aa62300...8cfa1e890f59
            Hide
            dogfood dogfood added a comment -

            Integrated in jenkins_main_trunk #4412
            [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null (Revision 42de07bba60bdde51ee7123ed6c65a11cddb78ae)

            Result = SUCCESS
            jesse glick : 42de07bba60bdde51ee7123ed6c65a11cddb78ae
            Files :

            • core/src/main/java/hudson/init/impl/GroovyInitScript.java
            • test/src/test/java/hudson/util/BootFailureTest.java
            • core/src/main/java/hudson/util/BootFailure.java
            • core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
            Show
            dogfood dogfood added a comment - Integrated in jenkins_main_trunk #4412 [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null (Revision 42de07bba60bdde51ee7123ed6c65a11cddb78ae) Result = SUCCESS jesse glick : 42de07bba60bdde51ee7123ed6c65a11cddb78ae Files : core/src/main/java/hudson/init/impl/GroovyInitScript.java test/src/test/java/hudson/util/BootFailureTest.java core/src/main/java/hudson/util/BootFailure.java core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
            Hide
            dogfood dogfood added a comment -

            Integrated in jenkins_2.0 #5
            [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null (Revision 42de07bba60bdde51ee7123ed6c65a11cddb78ae)

            Result = SUCCESS
            jesse glick : 42de07bba60bdde51ee7123ed6c65a11cddb78ae
            Files :

            • test/src/test/java/hudson/util/BootFailureTest.java
            • core/src/main/java/hudson/init/impl/GroovyInitScript.java
            • core/src/main/java/hudson/util/BootFailure.java
            • core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
            Show
            dogfood dogfood added a comment - Integrated in jenkins_2.0 #5 [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null (Revision 42de07bba60bdde51ee7123ed6c65a11cddb78ae) Result = SUCCESS jesse glick : 42de07bba60bdde51ee7123ed6c65a11cddb78ae Files : test/src/test/java/hudson/util/BootFailureTest.java core/src/main/java/hudson/init/impl/GroovyInitScript.java core/src/main/java/hudson/util/BootFailure.java core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            core/src/main/java/hudson/init/impl/GroovyInitScript.java
            core/src/main/java/hudson/util/BootFailure.java
            core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
            test/src/test/java/hudson/util/BootFailureTest.java
            http://jenkins-ci.org/commit/jenkins/db1f62835b4a2fa51c9a276d520ddb21694a35ba
            Log:
            [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null when we are running a boot failure script.
            (cherry picked from commit 42de07bba60bdde51ee7123ed6c65a11cddb78ae)

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/init/impl/GroovyInitScript.java core/src/main/java/hudson/util/BootFailure.java core/src/main/java/jenkins/util/groovy/GroovyHookScript.java test/src/test/java/hudson/util/BootFailureTest.java http://jenkins-ci.org/commit/jenkins/db1f62835b4a2fa51c9a276d520ddb21694a35ba Log: [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null when we are running a boot failure script. (cherry picked from commit 42de07bba60bdde51ee7123ed6c65a11cddb78ae)
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            core/src/main/java/hudson/init/impl/GroovyInitScript.java
            core/src/main/java/hudson/util/BootFailure.java
            core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
            test/src/test/java/hudson/util/BootFailureTest.java
            http://jenkins-ci.org/commit/jenkins/ef8ea8c6692f983886de4c5129e387577c886096
            Log:
            [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null when we are running a boot failure script.
            (cherry picked from commit 42de07bba60bdde51ee7123ed6c65a11cddb78ae)

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/init/impl/GroovyInitScript.java core/src/main/java/hudson/util/BootFailure.java core/src/main/java/jenkins/util/groovy/GroovyHookScript.java test/src/test/java/hudson/util/BootFailureTest.java http://jenkins-ci.org/commit/jenkins/ef8ea8c6692f983886de4c5129e387577c886096 Log: [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null when we are running a boot failure script. (cherry picked from commit 42de07bba60bdde51ee7123ed6c65a11cddb78ae)
            Hide
            dogfood dogfood added a comment -

            Integrated in jenkins_main_trunk #4436
            [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null (Revision db1f62835b4a2fa51c9a276d520ddb21694a35ba)

            Result = SUCCESS
            ogondza : db1f62835b4a2fa51c9a276d520ddb21694a35ba
            Files :

            • core/src/main/java/hudson/util/BootFailure.java
            • test/src/test/java/hudson/util/BootFailureTest.java
            • core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
            • core/src/main/java/hudson/init/impl/GroovyInitScript.java
            Show
            dogfood dogfood added a comment - Integrated in jenkins_main_trunk #4436 [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null (Revision db1f62835b4a2fa51c9a276d520ddb21694a35ba) Result = SUCCESS ogondza : db1f62835b4a2fa51c9a276d520ddb21694a35ba Files : core/src/main/java/hudson/util/BootFailure.java test/src/test/java/hudson/util/BootFailureTest.java core/src/main/java/jenkins/util/groovy/GroovyHookScript.java core/src/main/java/hudson/init/impl/GroovyInitScript.java
            Hide
            dogfood dogfood added a comment -

            Integrated in jenkins_main_trunk #4450
            [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null (Revision ef8ea8c6692f983886de4c5129e387577c886096)

            Result = SUCCESS
            ogondza : ef8ea8c6692f983886de4c5129e387577c886096
            Files :

            • core/src/main/java/hudson/init/impl/GroovyInitScript.java
            • core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
            • core/src/main/java/hudson/util/BootFailure.java
            • test/src/test/java/hudson/util/BootFailureTest.java
            Show
            dogfood dogfood added a comment - Integrated in jenkins_main_trunk #4450 [FIXED JENKINS-24696] Cannot assume that Jenkins.getInstance() != null (Revision ef8ea8c6692f983886de4c5129e387577c886096) Result = SUCCESS ogondza : ef8ea8c6692f983886de4c5129e387577c886096 Files : core/src/main/java/hudson/init/impl/GroovyInitScript.java core/src/main/java/jenkins/util/groovy/GroovyHookScript.java core/src/main/java/hudson/util/BootFailure.java test/src/test/java/hudson/util/BootFailureTest.java

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                danielbeck Daniel Beck
              • Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: