使用Log4j2 2.10.0运行Java 9模块 [英] Running Java 9 module using Log4j2 2.10.0

查看:170
本文介绍了使用Log4j2 2.10.0运行Java 9模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行我创建的Java 9模块,该模块使用Log4j2 2.10.0。

I am trying to run a Java 9 module I've created which uses Log4j2 2.10.0.

我遇到的问题是我得到了一个

The problem I'm running into is that I get a

java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil

在执行 LogManager.getLogger()时。它找到了LogManager类,但是当它从 StatusLogger 新的PropertiesUtil(log4j2.StatusLogger.properties)时c $ c>,它收到上述错误。

when doing a LogManager.getLogger(). It finds the LogManager class fine, but when it get to the new PropertiesUtil("log4j2.StatusLogger.properties") call from inside StatusLogger, it gets the above error.

如何修复/找到解决方法?

How do fix/find a workaround for this?

添加信息:

堆栈跟踪:

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil
    at org.apache.logging.log4j/org.apache.logging.log4j.status.StatusLogger.<clinit>(StatusLogger.java:71)
    at org.apache.logging.log4j/org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:60)
    at com.EvolutionarySoftwareSystems.Utilities/com.EvolutionarySoftwareSystems.Utilities.Base.DebugAble.<clinit>(DebugAble.java:45)

我可以直接调用调用的一个奇怪的事情:我的代码中的新PropertiesUtil(string)它找到了class。

One more odd thing I can directly call the invoke: new PropertiesUtil("string") from my code and it finds the class.

我正在使用eclipse氧气4.7.1a。

I am using eclipse oxygen 4.7.1a.

我的eclipse启动配置文件:

My eclipse launch config file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<setAttribute key="name.schedenig.eclipse.grepconsole.DisabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.EnabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.FilterDisabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.FilterEnabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.StatisticsDisabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.StatisticsEnabledIds"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Evolver/src/com/EvolutionarySoftwareSystems/Evolver/Server/EvolServer.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;EvolGrammarJava&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;Evolver&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;Base&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;classpathContainer path=&amp;quot;org.eclipse.jdt.launching.JRE_CONTAINER&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.classpathContainer&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;Annotations&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;Utilities&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.EvolutionarySoftwareSystems.Evolver.Server.EvolServer"/>
<listAttribute key="org.eclipse.jdt.launching.MODULEPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;4&quot; projectName=&quot;Evolver&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot; javaProject=&quot;Base&quot; path=&quot;4&quot; type=&quot;4&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;4&quot; projectName=&quot;Annotations&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;4&quot; projectName=&quot;Base&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;4&quot; projectName=&quot;Utilities&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;4&quot; projectName=&quot;EvolGrammarJava&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;C:/antlr/antlr-runtime-4.7.jar&quot; path=&quot;4&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;C:/xerces/xerces-2_11_0/xercesImpl.jar&quot; path=&quot;4&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;C:/log4j2/apache-log4j-2.10.0-bin/log4j-api-2.10.0.jar&quot; path=&quot;4&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;C:/apache/commons-lang3-3.7/commons-lang3-3.7.jar&quot; path=&quot;4&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/Evolver/Log4j2Config&quot; path=&quot;4&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="C:\eclipseWorkspace\evolver\src\Samples\S_01.evo"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Evolver"/>
</launchConfiguration>

模块文件:

module com.EvolutionarySoftwareSystems.Evolver {
    //
    // // Export the com.EvolutionarySoftwareSystems package
    //
    requires com.EvolutionarySoftwareSystems.Base;
    requires com.EvolutionarySoftwareSystems.Utilities;
    requires com.EvolutionarySoftwareSystems;
    requires java.base;
    requires java.xml;
    requires org.apache.logging.log4j;
    requires transitive xercesImpl;

    //
    exports com.EvolutionarySoftwareSystems.Evolver;

    //
    // provides com.EvolutionarySoftwareSystems.LsysEx.App.Main;
}


推荐答案

Log4j有一个问题报告见 https://issues.apache.org/jira/browse/LOG4J2-2129

要么使用2.9,要么使用2.10和我在该故障单中提供的解决方法,或者使用2.11,这是在几天前发布并修复了问题。

Log4j has an issue there which is reported at https://issues.apache.org/jira/browse/LOG4J2-2129.
Either use 2.9, or use 2.10 with the workaround I provided in that ticket or use 2.11 which was released a couple of days ago and fixes the issue.

这篇关于使用Log4j2 2.10.0运行Java 9模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆