环境:
1、Eclipse
Eclipse Java EE IDE for Web Developers.
Version: Luna Service Release 1 (4.4.1)
Build id: 20140925-1800
2、JBoss
jboss-as-7.1.0.CR1b
3、JDK
jdk1.7.0_67
4、操作系统
Win7 64位
问题现象:
在Eclipse中启动JBoss异常,Console输出如下:
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.jboss.as.server.Main.main(Main.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.modules.Module.run(Module.java:248)
at org.jboss.modules.Main.main(Main.java:313)
Caused by: java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager")
at org.jboss.logmanager.Logger.getLogger(Logger.java:60)
at org.jboss.logmanager.log4j.BridgeRepositorySelector.<clinit>(BridgeRepositorySelector.java:42)
... 7 more
原因分析:从Caused by可以看出,是启动JBoss时LogManger没有加载成功
解决方案:
1、在Servers示图中选中“JBoss AS 7.1”,双击或按下F3打开JBoss服务配置界面
2、点击“Open launch configuration”
3、在“Arguments”标签页中找到“VM arguments”,在参数配置里,找到“Djboss.modules.system.pkgs=org.jboss.byteman”,追加“org.jboss.logmanager”,注意“org.jboss.byteman”与新追加的“org.jboss.logmanager”之间要有逗号“,”,然后在最末尾加上"-Djava.util.logging.manager=org.jboss.logmanager.LogManager" ,修改后的完整参数如下所示:
"-Dprogram.name=JBossTools: JBoss AS 7.1" -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Djava.net.preferIPv4Stack=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager -Djava.awt.headless=true "-Dorg.jboss.boot.log.file=D:/jboss-as-7.1.0.CR1b/standalone/log/boot.log" "-Dlogging.configuration=file:/D:/jboss-as-7.1.0.CR1b/standalone/configuration/logging.properties" "-Djboss.home.dir=D:/jboss-as-7.1.0.CR1b" -Djboss.bind.address.management=localhost "-Djava.util.logging.manager=org.jboss.logmanager.LogManager"
4、在“Classpath”中添加以下三个Jar包:
%JBoss_Home%\modules\org\jboss\logmanager\main\jboss-logmanager-1.2.0.GA.jar
%JBoss_Home%\modules\org\jboss\logmanager\log4j\main\jboss-logmanager-log4j-1.0.0.GA.jar
%JBoss_Home%\modules\org\apache\log4j\main\log4j-1.2.16.jar
(我本机%JBoss_Home%的真实目录是D:\jboss-as-7.1.0.CR1b)
验证结果:
再次在Eclipse中启动JBoss,“Console”中异常输出消失,终于看到久违的 “started in 2538ms”