Window下ActiveMQ报错 LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle ...

文章标题有限,只能显示部分错误,具体错误显示如下:

运行环境:Win7系统

LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.apache.activemq.xbean.XBeanBrokerFactory$1@2cad3f16: startup date [Sat Apr 08 09:38:14 CST 2017]; root of context hierarchy
在网络上找了一堆回答,都说是计算机名中含有“-”或者“_”导致的,就把计算机名的“-”和“_”去掉,重启计算机,然后重启ActiveMQ仍然存在这样的问题。

经过仔细查看activemq.log日志

Window下ActiveMQ报错 LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle ..._第1张图片
查看全面一点的报错日志,具体如下:


2017-04-08 09:38:16,210 | ERROR | Failed to start Apache ActiveMQ ([localhost, ID:cos-1484-1491615496008-0:1], java.io.IOException: Transport Connector could not be registered in JMX: java.io.IOException: Failed to bind to server socket: mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600 due to: java.net.BindException: Address already in use: JVM_Bind) | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain
2017-04-08 09:38:16,226 | INFO  | Apache ActiveMQ 5.14.4 (localhost, ID:cos-1484-1491615496008-0:1) is shutting down | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain
2017-04-08 09:38:16,226 | INFO  | Connector openwire stopped | org.apache.activemq.broker.TransportConnector | WrapperSimpleAppMain
2017-04-08 09:38:16,242 | INFO  | Connector amqp stopped | org.apache.activemq.broker.TransportConnector | WrapperSimpleAppMain
2017-04-08 09:38:16,242 | INFO  | Connector stomp stopped | org.apache.activemq.broker.TransportConnector | WrapperSimpleAppMain
2017-04-08 09:38:16,242 | INFO  | Connector mqtt stopped | org.apache.activemq.broker.TransportConnector | WrapperSimpleAppMain
2017-04-08 09:38:16,242 | INFO  | Connector ws stopped | org.apache.activemq.broker.TransportConnector | WrapperSimpleAppMain
2017-04-08 09:38:16,242 | INFO  | PListStore:[E:\usr\local\activemq\bin\win64\..\..\data\localhost\tmp_storage] stopped | org.apache.activemq.store.kahadb.plist.PListStoreImpl | WrapperSimpleAppMain
2017-04-08 09:38:16,242 | INFO  | Stopping async queue tasks | org.apache.activemq.store.kahadb.KahaDBStore | WrapperSimpleAppMain
2017-04-08 09:38:16,257 | INFO  | Stopping async topic tasks | org.apache.activemq.store.kahadb.KahaDBStore | WrapperSimpleAppMain
2017-04-08 09:38:16,257 | INFO  | Stopped KahaDB | org.apache.activemq.store.kahadb.KahaDBStore | WrapperSimpleAppMain
2017-04-08 09:38:16,257 | INFO  | socketQueue interrupted - stopping | org.apache.activemq.transport.tcp.TcpTransportServer | ActiveMQ Transport Server Thread Handler: stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600
2017-04-08 09:38:16,257 | INFO  | Could not accept connection during shutdown  : java.lang.InterruptedException | org.apache.activemq.broker.TransportConnector | ActiveMQ Transport Server Thread Handler: stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600
2017-04-08 09:38:16,570 | INFO  | Apache ActiveMQ 5.14.4 (localhost, ID:cos-1484-1491615496008-0:1) uptime 0.890 seconds | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain
2017-04-08 09:38:16,570 | INFO  | Apache ActiveMQ 5.14.4 (localhost, ID:cos-1484-1491615496008-0:1) is shutdown | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain
2017-04-08 09:38:16,570 | INFO  | Closing org.apache.activemq.xbean.XBeanBrokerFactory$1@2cad3f16: startup date [Sat Apr 08 09:38:14 CST 2017]; root of context hierarchy | org.apache.activemq.xbean.XBeanBrokerFactory$1 | WrapperSimpleAppMain
2017-04-08 09:38:16,601 | WARN  | Exception thrown from LifecycleProcessor on context close | org.apache.activemq.xbean.XBeanBrokerFactory$1 | WrapperSimpleAppMain
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.apache.activemq.xbean.XBeanBrokerFactory$1@2cad3f16: startup date [Sat Apr 08 09:38:14 CST 2017]; root of context hierarchy
	at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:357)[spring-context-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:884)[spring-context-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:843)[spring-context-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.apache.activemq.hooks.SpringContextHook.run(SpringContextHook.java:30)[activemq-spring-5.14.4.jar:5.14.4]
	at org.apache.activemq.broker.BrokerService.stop(BrokerService.java:876)[activemq-broker-5.14.4.jar:5.14.4]
	at org.apache.activemq.xbean.XBeanBrokerService.stop(XBeanBrokerService.java:122)[activemq-spring-5.14.4.jar:5.14.4]
	at org.apache.activemq.broker.BrokerService.start(BrokerService.java:630)[activemq-broker-5.14.4.jar:5.14.4]
	at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:73)[activemq-spring-5.14.4.jar:5.14.4]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_79]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_79]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_79]
	at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_79]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1700)[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1639)[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)[spring-beans-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)[spring-context-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)[spring-context-4.1.9.RELEASE.jar:4.1.9.RELEASE]
	at org.apache.xbean.spring.context.ResourceXmlApplicationContext.(ResourceXmlApplicationContext.java:64)[xbean-spring-4.2.jar:4.2]
	at org.apache.xbean.spring.context.ResourceXmlApplicationContext.(ResourceXmlApplicationContext.java:52)[xbean-spring-4.2.jar:4.2]
	at org.apache.activemq.xbean.XBeanBrokerFactory$1.(XBeanBrokerFactory.java:104)[activemq-spring-5.14.4.jar:5.14.4]
	at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:104)[activemq-spring-5.14.4.jar:5.14.4]
	at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:67)[activemq-spring-5.14.4.jar:5.14.4]
	at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)[activemq-broker-5.14.4.jar:5.14.4]
	at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)[activemq-broker-5.14.4.jar:5.14.4]
	at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:87)[activemq-console-5.14.4.jar:5.14.4]
	at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:63)[activemq-console-5.14.4.jar:5.14.4]
	at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:154)[activemq-console-5.14.4.jar:5.14.4]
	at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:63)[activemq-console-5.14.4.jar:5.14.4]
	at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104)[activemq-console-5.14.4.jar:5.14.4]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_79]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_79]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_79]
	at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_79]
	at org.apache.activemq.console.Main.runTaskClass(Main.java:262)[activemq.jar:5.14.4]
	at org.apache.activemq.console.Main.main(Main.java:115)[activemq.jar:5.14.4]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_79]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_79]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_79]
	at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_79]
	at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)[wrapper.jar:3.2.3]
	at java.lang.Thread.run(Thread.java:745)[:1.7.0_79]
2017-04-08 09:38:16,742 | WARN  | Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.io.IOException: Transport Connector could not be registered in JMX: java.io.IOException: Failed to bind to server socket: mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600 due to: java.net.BindException: Address already in use: JVM_Bind | org.apache.activemq.xbean.XBeanBrokerFactory$1 | WrapperSimpleAppMain
实际的导致ActiveMQ启动报错的可能原因是MQTT的端口1883被占用

Failed to start Apache ActiveMQ ([localhost, ID:cos-1484-1491615496008-0:1], java.io.IOException: Transport Connector could not be registered in JMX: java.io.IOException: Failed to bind to server socket: mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600 due to: java.net.BindException: Address already in use: JVM_Bind) | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain

既然知道可能是端口占用,那么找到ActiveMQ的配置文件改掉端口即可,如下图:

Window下ActiveMQ报错 LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle ..._第2张图片


将MQTT的端口改掉即可,如果没有使用到MQTT,也可以把MQTT的配置项注释掉。

Window下ActiveMQ报错 LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle ..._第3张图片

还有另一种方法就是,先在cmd 下通过netstat -aon 找到1883对应的pid    然后通过任务管理器,找到对应的pid,将进程结束掉,当然这个进程是不影响你其他程序的运行的。

找错误尽可能的看报错信息全面点,不然很容易在百度上搜索老半天都找不到原因。

你可能感兴趣的:(ActiveMQ消息中间件)