今天在一个测试环境中启动jboss时,不能正常启动,后来找了一会儿才查到了原因,记录一下吧。
在jboss.log中可以看到“Could not create deployment: file:/usr/local/jboss/server/default/conf/jboss-service.xml”这样的记录,但我仔细查了一下并非权限的问题。后来找了很久原因,结合网上搜索,加上仔细看到了“Caused by: java.lang.RuntimeException: Exception creating identity: host_221-83: host_221-83”的记录;才基本确定了是由于hostname解析不了,所以jboss不能正常启动。
解决方案很简单,要么是配置DNS使其能够解析本机的hostname(可用命令hostname获取),要么修改/etc/hosts文件使其解析为127.0.0.1即可。
如,我的/etc/hosts就修改为如下,添加了本机的hostname为“host_221-83”。
1 |
127.0.0.1 host_221-83 localhost localhost.localdomain localhost4 localhost4.localdomain4 |
其实,网上其他人也会遇到这个问题的,至于为什么jboss启动需要去解析本机主机名,我也没有深入调查了。
网上其他人也遇到了类似问题,见:https://community.jboss.org/thread/64649?tstart=0
另外,顺手记录一个jboss启动的参数,加上 -b 0.0.0.0 或 --host=0.0.0.0 才能保证服务能够被域名/IP/localhost等方式访问到,否则默认是localhost才行。
1 |
/usr/local/jboss/bin/run.sh -b 0.0.0.0 |
关于遇到的jboss不能启动的问题的详细日志在jboss.log中,摘录如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
Listening for transport dt_socket at address: 8787 17:29:53,250 INFO [Server] Starting JBoss (MX MicroKernel)... 17:29:53,251 INFO [Server] Release ID: JBoss [Trinity] 4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139) 17:29:53,253 INFO [Server] Home Dir: /usr/local/jboss 17:29:53,253 INFO [Server] Home URL: file:/usr/local/jboss/ 17:29:53,254 INFO [Server] Patch URL: null 17:29:53,254 INFO [Server] Server Name: default 17:29:53,254 INFO [Server] Server Home Dir: /usr/local/jboss/server/default 17:29:53,254 INFO [Server] Server Home URL: file:/usr/local/jboss/server/default/ 17:29:53,254 INFO [Server] Server Log Dir: /usr/local/jboss/server/default/log 17:29:53,255 INFO [Server] Server Temp Dir: /usr/local/jboss/server/default/tmp 17:29:53,255 INFO [Server] Root Deployment Filename: jboss-service.xml 17:29:53,450 INFO [ServerInfo] Java version: 1.6.0_26,Sun Microsystems Inc. 17:29:53,451 INFO [ServerInfo] Java VM: Java HotSpot(TM) 64-Bit Server VM 20.1-b02,Sun Microsystems Inc. 17:29:53,451 INFO [ServerInfo] OS-System: Linux 2.6.32-279.el6.x86_64,amd64 17:29:53,667 INFO [Server] Core system initialized 17:29:54,714 WARN [BasicMBeanRegistry] javax.management.MBeanRegistrationException: preRegister() failed: [ObjectName='jboss.remoting:service=NetworkRegistry', Class=org.jboss.remoting.network.NetworkRegistry (org.jboss.remoting.network.NetworkRegistry@78688954)] 17:29:54,726 ERROR [MainDeployer] Could not create deployment: file:/usr/local/jboss/server/default/conf/jboss-service.xml org.jboss.deployment.DeploymentException: - nested throwable: (java.lang.reflect.InvocationTargetException) at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:196) at org.jboss.system.ServiceController.install(ServiceController.java:226) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy4.install(Unknown Source) at org.jboss.deployment.SARDeployer.create(SARDeployer.java:249) at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy5.deploy(Unknown Source) at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482) at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362) at org.jboss.Main.boot(Main.java:200) at org.jboss.Main$1.run(Main.java:508) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.reflect.InvocationTargetException at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:1451) at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:1350) at org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerImpl.java:345) at org.jboss.system.ServiceCreator.install(ServiceCreator.java:157) at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:451) at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:171) ... 36 more Caused by: javax.management.MBeanException at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptions(ReflectedDispatcher.java:180) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:163) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.server.MBeanServerImpl$3.run(MBeanServerImpl.java:1422) at java.security.AccessController.doPrivileged(Native Method) at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:1417) ... 41 more Caused by: javax.management.MBeanRegistrationException: preRegister() failed: [ObjectName='jboss.remoting:service=NetworkRegistry', Class=org.jboss.remoting.network.NetworkRegistry (org.jboss.remoting.network.NetworkRegistry@78688954)] at org.jboss.mx.server.registry.BasicMBeanRegistry.invokePreRegister(BasicMBeanRegistry.java:713) at org.jboss.mx.server.registry.BasicMBeanRegistry.registerMBean(BasicMBeanRegistry.java:211) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) ... 51 more Caused by: java.lang.RuntimeException: Exception creating identity: host_221-83: host_221-83 at org.jboss.remoting.ident.Identity.get(Identity.java:211) at org.jboss.remoting.network.NetworkRegistry.preRegister(NetworkRegistry.java:268) at org.jboss.mx.server.AbstractMBeanInvoker.invokePreRegister(AbstractMBeanInvoker.java:966) at org.jboss.mx.modelmbean.ModelMBeanInvoker.invokePreRegister(ModelMBeanInvoker.java:489) at org.jboss.mx.server.AbstractMBeanInvoker.preRegister(AbstractMBeanInvoker.java:654) at org.jboss.mx.server.registry.BasicMBeanRegistry.invokePreRegister(BasicMBeanRegistry.java:697) ... 56 more Failed to boot JBoss:... ....... 17:29:54,732 INFO [Server] Runtime shutdown hook called, forceHalt: true 17:29:54,732 INFO [Server] JBoss SHUTDOWN: Undeploying all packages 17:29:54,739 INFO [Server] Shutdown complete Shutdown complete Halting VM |