eclipse 带有 java.util.Logger 的 JBOSS AS 7.1 中的 LogManager 异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21134303/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
LogManager Exception in JBOSS AS 7.1 with java.util.Logger
提问by Anish Antony
I created a java application and initialize a java.util.Logger with that application and run that application as -javaagent
with jboss AS 7 server and i got IllegalStateException
(i am using eclipse IDE).Here follows my logger initialization code
我创建了一个 java 应用程序并使用该应用程序初始化 java.util.Logger 并像-javaagent
使用 jboss AS 7 服务器一样运行该应用程序,我得到了IllegalStateException
(我正在使用 eclipse IDE)。下面是我的记录器初始化代码
static public void setup() throws IOException {
// Get the global logger to configure it
Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
logger.setLevel(Level.INFO);
fileTxt = new FileHandler("C:/Users/abc/Desktop/ATAGENT/Logging.txt");
fileHTML = new FileHandler("C:/Users/abc/Desktop/ATAGENT/Logging.html");
// create txt Formatter
formatterTxt = new SimpleFormatter();
fileTxt.setFormatter(formatterTxt);
logger.addHandler(fileTxt);
// create HTML Formatter
formatterHTML = new BMITHtmlFormatter();
fileHTML.setFormatter(formatterHTML);
logger.addHandler(fileHTML);
}
When i create -javaagent
jar appended with above lines of code and run with jboss as7 server i got following exception
当我创建-javaagent
附加了上述代码行的 jar 并使用 jboss as7 服务器运行时,我得到了以下异常
WARNING: Failed to load the specified log manager class org.jboss.logmanager.LogManager
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.jboss.as.server.Main.main(Main.java:73)
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.modules.Module.run(Module.java:260)
at org.jboss.modules.Main.main(Main.java:291)
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.(BridgeRepositorySelector.java:42)
... 7 more
And i serched in fourms and i got a solutionwhich is Open the launch configuration for the server definition.
and add -logmodule org.jboss.logmanager
to the program arguments before org.jboss.as.standalone
.
But it results the same exception with some additional warning. Here follows the exception
我搜索了四分钟,我得到了一个解决方案,即打开服务器定义的启动配置。并添加-logmodule org.jboss.logmanager
到程序参数之前org.jboss.as.standalone
。但它会导致相同的异常并带有一些额外的警告。下面是例外
WARNING: -logmodule is deprecated. Please use the system property 'java.util.logging.manager' or the 'java.util.logging.LogManager' service loader.
WARNING: Failed to load the specified log manager class org.jboss.logmanager.LogManager
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.jboss.as.server.Main.main(Main.java:73)
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.modules.Module.run(Module.java:260)
at org.jboss.modules.Main.main(Main.java:291)
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.(BridgeRepositorySelector.java:42)
... 7 more
回答by bdurand
I had the same problem with JBOSS EAP 6, it take me 2 days for find a solution !.
我在 JBOSS EAP 6 上遇到了同样的问题,我花了 2 天时间才找到解决方案!
The cause is that your agent need to create a Logger at statup, he need to be able to access the logmanager classes before JBOSS Modules has been initialized. You need to add JBoss LogManager to the boot classloader. Then, there will be a conflict between LogManager available via ModuleClassLoader and classes loaded via system classloader.
原因是您的代理需要在 statup 时创建一个 Logger,他需要能够在 JBOSS Modules 初始化之前访问 logmanager 类。您需要将 JBoss LogManager 添加到引导类加载器。那么,通过 ModuleClassLoader 可用的 LogManager 和通过系统类加载器加载的类之间就会发生冲突。
The solution is to make Java Agent and JBoss Modules use the same classloader to load the LogManager classes.
解决方案是让 Java Agent 和 JBoss Modules 使用相同的类加载器来加载 LogManager 类。
For EAP 6, In your standalone.conf (or domain) (It must be close for your version)
对于 EAP 6,在您的 standalone.conf(或域)中(它必须与您的版本接近)
add
添加
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$JBOSS_HOME/modules/org/jboss/logmanager/main/jboss-logmanager-1.3.1.jar"
and for make Java Agent and JBoss Modules use the same classloader
并且为了使 Java 代理和 JBoss 模块使用相同的类加载器
modify this piece of code in adding org.jboss.logmanager like this :
在添加 org.jboss.logmanager 中修改这段代码,如下所示:
if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman,org.jboss.logmanager"
fi
Hope this will help.
希望这会有所帮助。
回答by cyeluri
I found the solution after searching for couple of days in the below link. https://github.com/jbossas/jboss-as-maven-plugin/issues/40#issuecomment-14943429
我在下面的链接中搜索了几天后找到了解决方案。 https://github.com/jbossas/jboss-as-maven-plugin/issues/40#issuecomment-14943429
I have to tweak a little bit to get is work in Windows 7.
我必须稍微调整一下才能在Windows 7 中工作。
- Open Eclipse.
- Add Jboss 7.1 Runtime 1 server.
- Select the Server and press F3.
- Click on Open Launch Config.
- Goto VM arguments.
- Add the below two entries.
- 打开日食。
- 添加 Jboss 7.1 运行时 1 服务器。
- 选择服务器并按 F3。
- 单击打开启动配置。
- 转到 VM 参数。
- 添加以下两个条目。
"-Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager" "-Djava.util.logging.manager=org.jboss.logmanager.LogManager"
"-Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager" "-Djava.util.logging.manager=org.jboss.logmanager.LogManager"
Now select the Classpath TAB
现在选择类路径选项卡
- Select User Entries
- Click Add External Jars
- Select the three jar files
- 选择用户条目
- 单击添加外部罐子
- 选择三个jar文件
a)jboss-logmanager-1.2.0.GA.jar b)jboss-logmanager-log4j-1.0.0.GA.jar c)log4j-1.2.16.jar
a)jboss-logmanager-1.2.0.GA.jar b)jboss-logmanager-log4j-1.0.0.GA.jar c)log4j-1.2.16.jar
Paths
路径
- C:/jboss-as-7.1.1.Final/modules/org/jboss/logmanager/main/jboss-logmanager-1.2.0.GA.jar"
- C:/jboss-as-7.1.1.Final/modules/org/jboss/logmanager/log4j/main/jboss-logmanager-log4j-1.0.0.GA.jar"
- C:/jboss-as-7.1.1.Final/modules/org/apache/log4j/main/log4j-1.2.16.jar"
- C:/jboss-as-7.1.1.Final/modules/org/jboss/logmanager/main/jboss-logmanager-1.2.0.GA.jar"
- C:/jboss-as-7.1.1.Final/modules/org/jboss/logmanager/log4j/main/jboss-logmanager-log4j-1.0.0.GA.jar"
- C:/jboss-as-7.1.1.Final/modules/org/apache/log4j/main/log4j-1.2.16.jar"
This will start the standalone jboss without any issues.
这将毫无问题地启动独立的 jboss。
回答by Matt
In EAP 6.4, the correct logmanager's path should be $JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-1.5.4.Final-redhat-1.jar
在 EAP 6.4 中,正确的日志管理器路径应该是 $JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-1.5.4.Final-redhat-1.jar