Jboss AS7 无法正常关闭
Posted
技术标签:
【中文标题】Jboss AS7 无法正常关闭【英文标题】:Jboss AS7 not shutting down properly 【发布时间】:2014-12-12 20:44:01 【问题描述】:我正在使用以下命令在 Windows 7 上关闭 Jboss AS7.2.0 的独立实例。
%JBOSS_HOME%\bin\jboss-cli.bat --connect controller=10.10.54.85:9999 --commands=:shutdown
但是,与 Jboss 关联的 java 进程并未终止。我看到这个进程的线程转储显示一些线程挂了一段时间,这些线程在很长一段时间(大约一个小时)后终止,然后进程自行完成。挂起的线程被命名为“JMX 服务器连接超时”(我不确定这是唯一的罪魁祸首)。并且日志反复显示一些 JMSEceptions,如下所示:
2014-10-17 08:34:07.811 GMT+0000 <@> ERROR <@> [1425:Thread-364] <@> ProcessId:1252 <@> PID:0 <@> UID:12 <@> HttpSessionId: <@> com.mypkg.platform.framework.event <@> getTopicConnection <@> Failed to create TopicConnection <@>
javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "org.hornetq:main" from local module loader @68a9ae3e (finder: local module finder @5bee9e20 (roots: D:\jboss-as-7.2.0.Final\modules,D:\jboss-as-7.2.0.Final\modules\system\layers\base))
at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at com.mypkg.platform.framework.event.Messenger.setupInitialContext(Messenger.java:915)
at com.mypkg.platform.framework.event.Messenger.getTopicConnectionFactory(Messenger.java:924)
at com.mypkg.platform.framework.event.Messenger.getTopicConnection(Messenger.java:1263)
at com.mypkg.platform.framework.event.Messenger.access$600(Messenger.java:103)
at com.mypkg.platform.framework.event.Messenger$ConnectionExceptionListener.onException(Messenger.java:1670)
at org.hornetq.jms.client.HornetQConnection$JMSFailureListener$1.run(HornetQConnection.java:697)
at java.lang.Thread.run(Thread.java:722)
2014-10-17 08:34:07.811 GMT+0000 <@> ERROR <@> [1425:Thread-364] <@> ProcessId:1252 <@> PID:0 <@> UID:12 <@> HttpSessionId: <@> com.mypkg.platform.framework.event <@> onException():TOPIC <@> Failed to establish Connection on attempt number: 30. Will retry after 10000 millis. Retry attempts remaining: 99970 <@>
javax.jms.JMSException: HornetQException[errorType=DISCONNECTED message=HQ119035: The connection was disconnected because of server shutdown]
at org.hornetq.jms.client.HornetQConnection$JMSFailureListener.connectionFailed(HornetQConnection.java:688)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.callSessionFailureListeners(ClientSessionFactoryImpl.java:963)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.failoverOrReconnect(ClientSessionFactoryImpl.java:740)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.handleConnectionFailure(ClientSessionFactoryImpl.java:580)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.access$100(ClientSessionFactoryImpl.java:85)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl$DelegatingFailureListener.connectionFailed(ClientSessionFactoryImpl.java:1674)
at org.hornetq.core.protocol.core.impl.RemotingConnectionImpl.callFailureListeners(RemotingConnectionImpl.java:570)
at org.hornetq.core.protocol.core.impl.RemotingConnectionImpl.fail(RemotingConnectionImpl.java:341)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl$CloseRunnable.run(ClientSessionFactoryImpl.java:1633)
at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:106)
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)
Caused by: HornetQException[errorType=DISCONNECTED message=HQ119035: The connection was disconnected because of server shutdown]
... 5 more
这是正确的根本原因吗?有人可以帮我解决这个问题吗?
【问题讨论】:
【参考方案1】:如果没有看到您对 JMS 连接的使用情况,很难回答这个问题,但是我建议您使用 @PreDestroy
方法注册一个 EJB,这样您就可以优雅地终止所有连接:
@Singleton
public class JMSDummyHandlerBean
@PostConstruct
public void init()
// Do your init here
@PreDestroy
public void tearDown()
// This will be called on server shutdown so you can kill all the active connections
【讨论】:
以上是关于Jboss AS7 无法正常关闭的主要内容,如果未能解决你的问题,请参考以下文章
如何让 Jenkins 将我的项目部署到 JBoss EAP(AS7)
jboss-as-maven-plugin 无法部署到远程 JBoss AS7?
JBoss AS7部署插件(jboss-as-maven-plugin)