java.lang.ClassCastException: org.springframework.context.event.ContextClosedEvent cannot be cast to com.wrox.site.Event1

Spring JIRA | Nick Williams | 4 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    This works: {code}@Service public class MyListener { @Bean public ApplicationListener<Event1> myListener$listener1() { return new ApplicationListener<Event1>() { @Override public void onApplicationEvent(Event1 event1) { System.out.println("Received Event1."); } }; } @Bean public ApplicationListener<Event2> myListener$listener2() { return new ApplicationListener<Event2>() { @Override public void onApplicationEvent(Event2 event1) { System.out.println("Received Event2."); } }; } }{code} These two variations do not: {code}@Service public class MyListener { @Bean public ApplicationListener<Event1> myListener$listener1() { return (Event1 e) -> { System.out.println("Received Event1."); }; } @Bean public ApplicationListener<Event2> myListener$listener2() { return (Event2 e) -> { System.out.println("Received Event2."); }; } }{code} {code}@Service public class MyListener { public void onEvent1(Event1 event1) { System.out.println("Received Event1."); } public void onEvent2(Event2 event2) { System.out.println("Received Event2."); } @Bean public ApplicationListener<Event1> myListener$listener1() { return this::onEvent1; } @Bean public ApplicationListener<Event2> myListener$listener2() { return this::onEvent2; } }{code} With either of these last two, Spring never starts. The following output is logged: {noformat}13:32:49.106 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.ContextLoader org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:273): Root WebApplicationContext: initialization started 13:32:49.109 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:524): Refreshing Root WebApplicationContext: startup date [Sun Jun 23 13:32:49 CDT 2013]; root of context hierarchy 13:32:49.215 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:233): JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning 13:32:49.217 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:241): JSR-330 'javax.inject.Named' annotation found and supported for component scanning 13:32:49.218 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.web.context.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions(AnnotationConfigWebApplicationContext.java:210): Registering annotated classes: [class com.wrox.config.RootContextConfiguration] 13:32:49.512 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:233): JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning 13:32:49.512 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:241): JSR-330 'javax.inject.Named' annotation found and supported for component scanning 13:32:49.807 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.<init>(AutowiredAnnotationBeanPostProcessor.java:140): JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 13:32:49.859 [RMI TCP Connection(3)-127.0.0.1] INFO com.wrox.config.RootContextConfiguration com.wrox.config.RootContextConfiguration.initialize(RootContextConfiguration.java:120): Setting up thread pool task scheduler with 20 threads. 13:32:49.922 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'rootContextConfiguration' of type [class com.wrox.config.RootContextConfiguration$$EnhancerByCGLIB$$45668b0d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 13:32:49.930 [RMI TCP Connection(3)-127.0.0.1] INFO com.wrox.config.RootContextConfiguration com.wrox.config.RootContextConfiguration.getAsyncExecutor(RootContextConfiguration.java:106): Configuring asynchronous method executor org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler@6f83de8a. 13:32:49.939 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'org.springframework.scheduling.annotation.ProxyAsyncConfiguration' of type [class org.springframework.scheduling.annotation.ProxyAsyncConfiguration$$EnhancerByCGLIB$$80f4fcd1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 13:32:49.994 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'org.springframework.scheduling.annotation.SchedulingConfiguration' of type [class org.springframework.scheduling.annotation.SchedulingConfiguration$$EnhancerByCGLIB$$b4ccf16b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 13:32:50.034 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'messageSource' of type [class org.springframework.context.support.ReloadableResourceBundleMessageSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 13:32:50.175 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'localValidatorFactoryBean' of type [class org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 13:32:50.197 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:611): Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@75c729d4: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,rootContextConfiguration,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,myListener,myListener$listener1,myListener$listener2,org.springframework.scheduling.annotation.ProxyAsyncConfiguration,org.springframework.context.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.SchedulingConfiguration,org.springframework.context.annotation.internalScheduledAnnotationProcessor,messageSource,objectMapper,taskScheduler,localValidatorFactoryBean,methodValidationPostProcessor,jaxb2Marshaller]; root of factory hierarchy 13:32:50.443 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler org.springframework.scheduling.concurrent.ExecutorConfigurationSupport.initialize(ExecutorConfigurationSupport.java:161): Initializing ExecutorService 'taskScheduler' 13:32:50.462 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.oxm.jaxb.Jaxb2Marshaller org.springframework.oxm.jaxb.Jaxb2Marshaller.createJaxbContextFromPackages(Jaxb2Marshaller.java:484): Creating JAXBContext by scanning packages [com.wrox.site] 13:32:50.542 [RMI TCP Connection(3)-127.0.0.1] ERROR org.springframework.web.context.ContextLoader org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:319): Context initialization failed java.lang.ClassCastException: org.springframework.context.event.ContextRefreshedEvent cannot be cast to com.wrox.site.Event1 at com.wrox.site.MyListener$$Lambda$3.onApplicationEvent(Unknown Source) ~[MyListener.class:?] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:344) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:496) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) ~[spring-web-4.0.0.M1.jar:4.0.0.M1] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-4.0.0.M1.jar:4.0.0.M1] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.0.0.M1.jar:4.0.0.M1] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5210) [catalina.jar:8.0.0-dev] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698) [catalina.jar:8.0.0-dev] at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1491) [catalina.jar:8.0.0-dev] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:468) [catalina.jar:8.0.0-dev] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:415) [catalina.jar:8.0.0-dev] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1465) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:75) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1306) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1398) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827) [?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) [?:1.8.0-ea] at sun.rmi.transport.Transport$1.run(Transport.java:177) [?:1.8.0-ea] at sun.rmi.transport.Transport$1.run(Transport.java:174) [?:1.8.0-ea] at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0-ea] at sun.rmi.transport.Transport.serviceCall(Transport.java:173) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670) [?:1.8.0-ea] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.8.0-ea] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.8.0-ea] at java.lang.Thread.run(Thread.java:724) [?:1.8.0-ea] 13:32:50.563 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1045): Closing Root WebApplicationContext: startup date [Sun Jun 23 13:32:49 CDT 2013]; root of context hierarchy 13:32:50.570 [RMI TCP Connection(3)-127.0.0.1] WARN org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1055): Exception thrown from ApplicationListener handling ContextClosedEvent java.lang.ClassCastException: org.springframework.context.event.ContextClosedEvent cannot be cast to com.wrox.site.Event1 at com.wrox.site.MyListener$$Lambda$3.onApplicationEvent(Unknown Source) ~[MyListener.class:?] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:344) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1052) [spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1013) [spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559) [spring-web-4.0.0.M1.jar:4.0.0.M1] at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115) [spring-web-4.0.0.M1.jar:4.0.0.M1] at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4805) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5414) [catalina.jar:8.0.0-dev] at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) [catalina.jar:8.0.0-dev] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698) [catalina.jar:8.0.0-dev] at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1491) [catalina.jar:8.0.0-dev] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:468) [catalina.jar:8.0.0-dev] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:415) [catalina.jar:8.0.0-dev] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1465) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:75) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1306) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1398) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827) [?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) [?:1.8.0-ea] at sun.rmi.transport.Transport$1.run(Transport.java:177) [?:1.8.0-ea] at sun.rmi.transport.Transport$1.run(Transport.java:174) [?:1.8.0-ea] at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0-ea] at sun.rmi.transport.Transport.serviceCall(Transport.java:173) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670) [?:1.8.0-ea] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.8.0-ea] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.8.0-ea] at java.lang.Thread.run(Thread.java:724) [?:1.8.0-ea] 13:32:50.573 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:452): Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@75c729d4: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,rootContextConfiguration,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,myListener,myListener$listener1,myListener$listener2,org.springframework.scheduling.annotation.ProxyAsyncConfiguration,org.springframework.context.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.SchedulingConfiguration,org.springframework.context.annotation.internalScheduledAnnotationProcessor,messageSource,objectMapper,taskScheduler,localValidatorFactoryBean,methodValidationPostProcessor,jaxb2Marshaller]; root of factory hierarchy 13:32:50.573 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler org.springframework.scheduling.concurrent.ExecutorConfigurationSupport.shutdown(ExecutorConfigurationSupport.java:199): Shutting down ExecutorService 'taskScheduler'{noformat} It seems to me that this should work. Perhaps a tweak to the listener registry to detect the method argument type from lambdas and references, too, instead of just regular and anonymous classes.

    Spring JIRA | 4 years ago | Nick Williams
    java.lang.ClassCastException: org.springframework.context.event.ContextClosedEvent cannot be cast to com.wrox.site.Event1
  2. 0

    This works: {code}@Service public class MyListener { @Bean public ApplicationListener<Event1> myListener$listener1() { return new ApplicationListener<Event1>() { @Override public void onApplicationEvent(Event1 event1) { System.out.println("Received Event1."); } }; } @Bean public ApplicationListener<Event2> myListener$listener2() { return new ApplicationListener<Event2>() { @Override public void onApplicationEvent(Event2 event1) { System.out.println("Received Event2."); } }; } }{code} These two variations do not: {code}@Service public class MyListener { @Bean public ApplicationListener<Event1> myListener$listener1() { return (Event1 e) -> { System.out.println("Received Event1."); }; } @Bean public ApplicationListener<Event2> myListener$listener2() { return (Event2 e) -> { System.out.println("Received Event2."); }; } }{code} {code}@Service public class MyListener { public void onEvent1(Event1 event1) { System.out.println("Received Event1."); } public void onEvent2(Event2 event2) { System.out.println("Received Event2."); } @Bean public ApplicationListener<Event1> myListener$listener1() { return this::onEvent1; } @Bean public ApplicationListener<Event2> myListener$listener2() { return this::onEvent2; } }{code} With either of these last two, Spring never starts. The following output is logged: {noformat}13:32:49.106 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.ContextLoader org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:273): Root WebApplicationContext: initialization started 13:32:49.109 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:524): Refreshing Root WebApplicationContext: startup date [Sun Jun 23 13:32:49 CDT 2013]; root of context hierarchy 13:32:49.215 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:233): JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning 13:32:49.217 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:241): JSR-330 'javax.inject.Named' annotation found and supported for component scanning 13:32:49.218 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.web.context.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions(AnnotationConfigWebApplicationContext.java:210): Registering annotated classes: [class com.wrox.config.RootContextConfiguration] 13:32:49.512 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:233): JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning 13:32:49.512 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:241): JSR-330 'javax.inject.Named' annotation found and supported for component scanning 13:32:49.807 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.<init>(AutowiredAnnotationBeanPostProcessor.java:140): JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 13:32:49.859 [RMI TCP Connection(3)-127.0.0.1] INFO com.wrox.config.RootContextConfiguration com.wrox.config.RootContextConfiguration.initialize(RootContextConfiguration.java:120): Setting up thread pool task scheduler with 20 threads. 13:32:49.922 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'rootContextConfiguration' of type [class com.wrox.config.RootContextConfiguration$$EnhancerByCGLIB$$45668b0d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 13:32:49.930 [RMI TCP Connection(3)-127.0.0.1] INFO com.wrox.config.RootContextConfiguration com.wrox.config.RootContextConfiguration.getAsyncExecutor(RootContextConfiguration.java:106): Configuring asynchronous method executor org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler@6f83de8a. 13:32:49.939 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'org.springframework.scheduling.annotation.ProxyAsyncConfiguration' of type [class org.springframework.scheduling.annotation.ProxyAsyncConfiguration$$EnhancerByCGLIB$$80f4fcd1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 13:32:49.994 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'org.springframework.scheduling.annotation.SchedulingConfiguration' of type [class org.springframework.scheduling.annotation.SchedulingConfiguration$$EnhancerByCGLIB$$b4ccf16b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 13:32:50.034 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'messageSource' of type [class org.springframework.context.support.ReloadableResourceBundleMessageSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 13:32:50.175 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'localValidatorFactoryBean' of type [class org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 13:32:50.197 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:611): Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@75c729d4: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,rootContextConfiguration,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,myListener,myListener$listener1,myListener$listener2,org.springframework.scheduling.annotation.ProxyAsyncConfiguration,org.springframework.context.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.SchedulingConfiguration,org.springframework.context.annotation.internalScheduledAnnotationProcessor,messageSource,objectMapper,taskScheduler,localValidatorFactoryBean,methodValidationPostProcessor,jaxb2Marshaller]; root of factory hierarchy 13:32:50.443 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler org.springframework.scheduling.concurrent.ExecutorConfigurationSupport.initialize(ExecutorConfigurationSupport.java:161): Initializing ExecutorService 'taskScheduler' 13:32:50.462 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.oxm.jaxb.Jaxb2Marshaller org.springframework.oxm.jaxb.Jaxb2Marshaller.createJaxbContextFromPackages(Jaxb2Marshaller.java:484): Creating JAXBContext by scanning packages [com.wrox.site] 13:32:50.542 [RMI TCP Connection(3)-127.0.0.1] ERROR org.springframework.web.context.ContextLoader org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:319): Context initialization failed java.lang.ClassCastException: org.springframework.context.event.ContextRefreshedEvent cannot be cast to com.wrox.site.Event1 at com.wrox.site.MyListener$$Lambda$3.onApplicationEvent(Unknown Source) ~[MyListener.class:?] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:344) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:496) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) ~[spring-web-4.0.0.M1.jar:4.0.0.M1] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-4.0.0.M1.jar:4.0.0.M1] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.0.0.M1.jar:4.0.0.M1] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5210) [catalina.jar:8.0.0-dev] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698) [catalina.jar:8.0.0-dev] at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1491) [catalina.jar:8.0.0-dev] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:468) [catalina.jar:8.0.0-dev] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:415) [catalina.jar:8.0.0-dev] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1465) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:75) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1306) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1398) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827) [?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) [?:1.8.0-ea] at sun.rmi.transport.Transport$1.run(Transport.java:177) [?:1.8.0-ea] at sun.rmi.transport.Transport$1.run(Transport.java:174) [?:1.8.0-ea] at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0-ea] at sun.rmi.transport.Transport.serviceCall(Transport.java:173) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670) [?:1.8.0-ea] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.8.0-ea] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.8.0-ea] at java.lang.Thread.run(Thread.java:724) [?:1.8.0-ea] 13:32:50.563 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1045): Closing Root WebApplicationContext: startup date [Sun Jun 23 13:32:49 CDT 2013]; root of context hierarchy 13:32:50.570 [RMI TCP Connection(3)-127.0.0.1] WARN org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1055): Exception thrown from ApplicationListener handling ContextClosedEvent java.lang.ClassCastException: org.springframework.context.event.ContextClosedEvent cannot be cast to com.wrox.site.Event1 at com.wrox.site.MyListener$$Lambda$3.onApplicationEvent(Unknown Source) ~[MyListener.class:?] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:344) ~[spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1052) [spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1013) [spring-context-4.0.0.M1.jar:4.0.0.M1] at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559) [spring-web-4.0.0.M1.jar:4.0.0.M1] at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115) [spring-web-4.0.0.M1.jar:4.0.0.M1] at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4805) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5414) [catalina.jar:8.0.0-dev] at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) [catalina.jar:8.0.0-dev] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702) [catalina.jar:8.0.0-dev] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698) [catalina.jar:8.0.0-dev] at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1491) [catalina.jar:8.0.0-dev] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:468) [catalina.jar:8.0.0-dev] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:415) [catalina.jar:8.0.0-dev] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1465) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:75) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1306) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1398) [?:1.8.0-ea] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827) [?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea] at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) [?:1.8.0-ea] at sun.rmi.transport.Transport$1.run(Transport.java:177) [?:1.8.0-ea] at sun.rmi.transport.Transport$1.run(Transport.java:174) [?:1.8.0-ea] at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0-ea] at sun.rmi.transport.Transport.serviceCall(Transport.java:173) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811) [?:1.8.0-ea] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670) [?:1.8.0-ea] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.8.0-ea] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.8.0-ea] at java.lang.Thread.run(Thread.java:724) [?:1.8.0-ea] 13:32:50.573 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:452): Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@75c729d4: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,rootContextConfiguration,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,myListener,myListener$listener1,myListener$listener2,org.springframework.scheduling.annotation.ProxyAsyncConfiguration,org.springframework.context.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.SchedulingConfiguration,org.springframework.context.annotation.internalScheduledAnnotationProcessor,messageSource,objectMapper,taskScheduler,localValidatorFactoryBean,methodValidationPostProcessor,jaxb2Marshaller]; root of factory hierarchy 13:32:50.573 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler org.springframework.scheduling.concurrent.ExecutorConfigurationSupport.shutdown(ExecutorConfigurationSupport.java:199): Shutting down ExecutorService 'taskScheduler'{noformat} It seems to me that this should work. Perhaps a tweak to the listener registry to detect the method argument type from lambdas and references, too, instead of just regular and anonymous classes.

    Spring JIRA | 4 years ago | Nick Williams
    java.lang.ClassCastException: org.springframework.context.event.ContextClosedEvent cannot be cast to com.wrox.site.Event1
  3. 0

    Help:basic RMI question

    Google Groups | 2 decades ago | Paolo De Lutiis
    java.lang.ClassCastException: serverPackage.ServerClass_Stub at clientPackage.myApplet.init(myApplet.java:line#) at sun.applet.AppletPanel.run(AppletPanel.java:273) at java.lang.Thread.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Shared hosting Bungeecord problems.

    GitHub | 3 years ago | Arksenu
    java.lang.ClassCastException: bka cannot be cast to fs All my servers are set to onlinemode: false Here is my config.yml groups: arksenu: - admin disabled_commands: - find player_limit: -1 stats: 347d1d62-6fb6-4869-bd43-7d0745de8e3c permissions: default: - bungeecord.command.server - bungeecord.command.list admin: - bungeecord.command.ip - bungeecord.command.alert - bungeecord.command.end - bungeecord.command.reload listeners: - max_players: 18 fallback_server: hub host: 0.0.0.0:35289 bind_local_address: true ping_passthrough: false tab_list: GLOBAL_PING default_server: hub forced_hosts: pvp.md-5.net: hub tab_size: 60 force_default_server: true motd: ’Network’ query_enabled: false query_port: 25565 timeout: 30000 connection_throttle: 4000 servers: hub: address: 108.170.8.146:35289 restricted: false motd: test UvGames: address: 66.85.165.170:26200 restricted: false motd: test UvPrison: address: 66.85.128.90:25928 restricted: false motd: test ip_forward: false online_mode: true And here is my console message -> UpstreamBridge has disconnected disconnected with: Exception Connecting:RuntimeException : Server is online mode! @ net.md_5.bungee.ServerConnector:188
  6. 0

    Shared hosting Bungeecord problems.

    GitHub | 3 years ago | Arksenu
    java.lang.ClassCastException: bka cannot be cast to fs All my servers are set to onlinemode: false Here is my config.yml groups: arksenu: - admin disabled_commands: - find player_limit: -1 stats: 347d1d62-6fb6-4869-bd43-7d0745de8e3c permissions: default: - bungeecord.command.server - bungeecord.command.list admin: - bungeecord.command.ip - bungeecord.command.alert - bungeecord.command.end - bungeecord.command.reload listeners: - max_players: 18 fallback_server: hub host: 0.0.0.0:35289 bind_local_address: true ping_passthrough: false tab_list: GLOBAL_PING default_server: hub forced_hosts: pvp.md-5.net: hub tab_size: 60 force_default_server: true motd: ’Network’ query_enabled: false query_port: 25565 timeout: 30000 connection_throttle: 4000 servers: hub: address: 108.170.8.146:35289 restricted: false motd: test UvGames: address: 66.85.165.170:26200 restricted: false motd: test UvPrison: address: 66.85.128.90:25928 restricted: false motd: test ip_forward: false online_mode: true And here is my console message -> UpstreamBridge has disconnected disconnected with: Exception Connecting:RuntimeException : Server is online mode! @ net.md_5.bungee.ServerConnector:188

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      org.springframework.context.event.ContextClosedEvent cannot be cast to com.wrox.site.Event1

      at com.wrox.site.MyListener$$Lambda$3.onApplicationEvent()
    2. com.wrox.site
      MyListener$$Lambda$3.onApplicationEvent
      1. com.wrox.site.MyListener$$Lambda$3.onApplicationEvent(Unknown Source)[MyListener.class:?]
      1 frame
    3. Spring Context
      AbstractApplicationContext.close
      1. org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98)[spring-context-4.0.0.M1.jar:4.0.0.M1]
      2. org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:344)[spring-context-4.0.0.M1.jar:4.0.0.M1]
      3. org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1052)[spring-context-4.0.0.M1.jar:4.0.0.M1]
      4. org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1013)[spring-context-4.0.0.M1.jar:4.0.0.M1]
      4 frames
    4. Spring
      ContextLoaderListener.contextDestroyed
      1. org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)[spring-web-4.0.0.M1.jar:4.0.0.M1]
      2. org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)[spring-web-4.0.0.M1.jar:4.0.0.M1]
      2 frames
    5. Glassfish Core
      HostConfig.manageApp
      1. org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4805)[catalina.jar:8.0.0-dev]
      2. org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5414)[catalina.jar:8.0.0-dev]
      3. org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)[catalina.jar:8.0.0-dev]
      4. org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)[catalina.jar:8.0.0-dev]
      5. org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)[catalina.jar:8.0.0-dev]
      6. org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)[catalina.jar:8.0.0-dev]
      7. org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698)[catalina.jar:8.0.0-dev]
      8. org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1491)[catalina.jar:8.0.0-dev]
      8 frames
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[?:1.8.0-ea]
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[?:1.8.0-ea]
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[?:1.8.0-ea]
      4. java.lang.reflect.Method.invoke(Method.java:491)[?:1.8.0-ea]
      4 frames
    7. Embedded GlassFish Web
      BaseModelMBean.invoke
      1. org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)[tomcat-coyote.jar:8.0.0-dev]
      1 frame
    8. Java RT
      JmxMBeanServer.invoke
      1. com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)[?:1.8.0-ea]
      2. com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792)[?:1.8.0-ea]
      2 frames
    9. Embedded GlassFish Web
      MBeanFactory.createStandardContext
      1. org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:468)[catalina.jar:8.0.0-dev]
      2. org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:415)[catalina.jar:8.0.0-dev]
      2 frames
    10. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[?:1.8.0-ea]
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[?:1.8.0-ea]
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[?:1.8.0-ea]
      4. java.lang.reflect.Method.invoke(Method.java:491)[?:1.8.0-ea]
      4 frames
    11. Embedded GlassFish Web
      BaseModelMBean.invoke
      1. org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)[tomcat-coyote.jar:8.0.0-dev]
      1 frame
    12. Java RT
      Thread.run
      1. com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)[?:1.8.0-ea]
      2. com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792)[?:1.8.0-ea]
      3. javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1465)[?:1.8.0-ea]
      4. javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:75)[?:1.8.0-ea]
      5. javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1306)[?:1.8.0-ea]
      6. javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1398)[?:1.8.0-ea]
      7. javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827)[?:1.8.0-ea]
      8. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[?:1.8.0-ea]
      9. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[?:1.8.0-ea]
      10. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[?:1.8.0-ea]
      11. java.lang.reflect.Method.invoke(Method.java:491)[?:1.8.0-ea]
      12. sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)[?:1.8.0-ea]
      13. sun.rmi.transport.Transport$1.run(Transport.java:177)[?:1.8.0-ea]
      14. sun.rmi.transport.Transport$1.run(Transport.java:174)[?:1.8.0-ea]
      15. java.security.AccessController.doPrivileged(Native Method)[?:1.8.0-ea]
      16. sun.rmi.transport.Transport.serviceCall(Transport.java:173)[?:1.8.0-ea]
      17. sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)[?:1.8.0-ea]
      18. sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)[?:1.8.0-ea]
      19. sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)[?:1.8.0-ea]
      20. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[?:1.8.0-ea]
      21. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[?:1.8.0-ea]
      22. java.lang.Thread.run(Thread.java:724)[?:1.8.0-ea]
      22 frames