Created https://issues.jboss.org/browse/KEYCLOAK-1507.

Cheers
Matt

On Mon, Jun 29, 2015 at 6:13 PM, Marko Strukelj <mstrukel@redhat.com> wrote:
Makes perfect sense to add a null check. Could you open a JIRA for this?  Or even provide a fix :)

Thanks.

----- Original Message -----
> Looking at this a bit closer it seems that Tomcat 7.0.35 will call stop() if
> the lifecycle state is set to FAILED.
>
> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.35/org/apache/catalina/util/LifecycleBase.java
> line 141.
>
> On Mon, Jun 29, 2015 at 9:45 AM, Matthew Casperson <
> matthew.casperson@autogeneral.com.au > wrote:
>
>
>
> I have been seeing this a bit recently (I'm using KeyCloak 1.2.0). I haven't
> tracked down a reproducible test case yet, but I'm wondering if there are
> situations where Tomcat will attempt to stop the value before it is started,
> which leads to nodesRegistrationManagement being null.
>
> Maybe it is worth adding a null check in
> AbstractKeycloakAuthenticatorValve.beforeStop()?
>
> java.lang.NullPointerException
> at
> org.keycloak.adapters.tomcat.AbstractKeycloakAuthenticatorValve.beforeStop(AbstractKeycloakAuthenticatorValve.java:130)
> at
> org.keycloak.adapters.tomcat.AbstractKeycloakAuthenticatorValve.lifecycleEvent(AbstractKeycloakAuthenticatorValve.java:67)
> at
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> at
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
> at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
> at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:272)
> at
> org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1041)
> at
> org.apache.catalina.startup.HostConfig.deleteRedeployResources(HostConfig.java:1300)
> at
> org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1251)
> at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1460)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> at
> org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
> at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
> at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
> at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1445)
> at
> org.apache.catalina.manager.ManagerServlet.undeploy(ManagerServlet.java:1381)
> at
> org.apache.catalina.manager.HTMLManagerServlet.undeploy(HTMLManagerServlet.java:674)
> at
> org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:215)
> 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.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:581)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> at
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
> at
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
> at
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)
>
> --
> Matthew Casperson
> Senior Front End Developer
> Technology, Space & Distribution
> Auto & General Holdings Pty Ltd
> P: 07) 3377 8751 (Direct: 3377 8751 )
> F: 07) 3377 8833
>
>
>
>
>
> --
> Matthew Casperson
> Senior Front End Developer
> Technology, Space & Distribution
> Auto & General Holdings Pty Ltd
> P: 07) 3377 8751 (Direct: 3377 8751 )
> F: 07) 3377 8833
>
>
>
> This email is sent by Auto & General Insurance Company Ltd, Auto & General
> Services Pty Ltd, Auto & General Holdings Pty Ltd or a related body
> corporate (Auto & General) and is for the intended addressee.
> The views expressed in this email and attachments (email) reflect the views
> of the stated author but may not reflect views of Auto & General. This email
> is confidential and subject to copyright.
> It may be privileged. If you are not the intended addressee, confidentiality
> and privilege have not been waived and any use, interference with, or
> disclosure of this email is unauthorised.
> If you are not the intended addressee please immediately notify the sender
> and then delete the email. Auto & General does not warrant that this email
> is error or virus free.
>
> _______________________________________________
> keycloak-dev mailing list
> keycloak-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-dev



--
Matthew Casperson
Senior Front End Developer
Technology, Space & Distribution
Auto & General Holdings Pty Ltd
P: 07) 3377 8751 (Direct: 3377 8751)
F: 07) 3377 8833



This email is sent by Auto & General Insurance Company Ltd, Auto & General Services Pty Ltd, Auto & General Holdings Pty Ltd or a related body corporate (Auto & General) and is for the intended addressee.
The views expressed in this email and attachments (email) reflect the views of the stated author but may not reflect views of Auto & General. This email is confidential and subject to copyright. 
It may be privileged. If you are not the intended addressee, confidentiality and privilege have not been waived and any use, interference with, or disclosure of this email is unauthorised. 
If you are not the intended addressee please immediately notify the sender and then delete the email. Auto & General does not warrant that this email is error or virus free.