webentwicklung-frage-antwort-db.com.de

Fehler beim Scannen des Eintrags META-INF / versions / 9 / org / Apache / logging / log4j / util / StackLocator.class mit Jetty und log4j 2.9.1?

Dies ist das Verzeichnislayout, das ich in meinem Maven-Projekt habe:

.
├── pom.xml
└── src
    └── main
        ├── Java
        │   └── biz
        │       └── tugay
        │           └── web
        │               └── servlet
        │                   └── MainServlet.Java
        ├── resources
        │   └── log4j.properties
        └── webapp
            └── WEB-INF
                └── web.xml

pom.xml relavent Teile wie folgt:

</dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.Apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>${log4j.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.Apache.logging.log4j</groupId>
        <artifactId>log4j-jcl</artifactId>
        <version>${log4j.version}</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

<build>
    <finalName>bare-webapp</finalName>
    <plugins>
        <plugin>
            <groupId>org.Eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.1.v20140609</version>
        </plugin>
    </plugins>
</build>

<properties>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <log4j.version>2.8.2</log4j.version>
</properties>

Und hier ist meine web.xml

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                             http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
</web-app>

und schließlich sieht log4j.properties so aus:

# suppress inspection "UnusedProperty" for whole file

# logger level configurations
log4j.rootLogger=ALL, console

# configuration for console outputs
log4j.appender.console=org.Apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.Apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=[%t] %-5p %c - %m%n

Zur Zeit läuft also alles gut (ich starte mit: mvn jetty: start) und wenn ich "/" besuche, sehe ich in der Konsole:

20:38:09.433 [qtp1503674351-26] ERROR biz.tugay.web.servlet.MainServlet - Serving request!

Das ist alles in Ordnung ..

<log4j.version>2.9.1</log4j.version>

nach Anlegesteg: Start bekomme ich:

[WARNING] Failed startup of context [email protected]{/,file:/Users/koraytugay/bare-webapp/src/main/webapp/,STARTING}{file:/Users/koraytugay/bare-webapp/src/main/webapp/}
MultiException[Java.lang.RuntimeException: Error scanning entry META-INF/versions/9/org/Apache/logging/log4j/util/ProcessIdUtil.class from jar file:/Users/koraytugay/.m2/repository/org/Apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar, Java.lang.RuntimeException: Error scanning entry META-INF/versions/9/org/Apache/logging/log4j/util/StackLocator.class from jar file:/Users/koraytugay/.m2/repository/org/Apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar]
    at org.Eclipse.jetty.annotations.AnnotationConfiguration.scanForAnnotations(AnnotationConfiguration.Java:530)
    at org.Eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.Java:441)
    at org.Eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.Java:471)
    at org.Eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.Java:1329)
    at org.Eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.Java:744)
    at org.Eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.Java:497)
    at org.Eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.Java:281)
    at org.Eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.Java:68)
    at org.Eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.Java:132)
    at org.Eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.Java:114)
    at org.Eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.Java:60)
    at org.Eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.Java:154)
    at org.Eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.Java:68)
    at org.Eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.Java:132)
    at org.Eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.Java:114)
    at org.Eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.Java:60)
    at org.Eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.Java:68)
    at org.Eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.Java:132)
    at org.Eclipse.jetty.server.Server.start(Server.Java:357)
    at org.Eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.Java:114)
    at org.Eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.Java:60)
    at org.Eclipse.jetty.server.Server.doStart(Server.Java:324)
    at org.Eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.Java:68)
    at org.Eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.Java:68)
    at org.Eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.Java:564)
    at org.Eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.Java:360)
    at org.Eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.Java:168)
    at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:134)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:207)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:153)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:145)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:116)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:80)
    at org.Apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.Java:51)
    at org.Apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.Java:128)
    at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:307)
    at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:193)
    at org.Apache.maven.DefaultMaven.execute(DefaultMaven.Java:106)
    at org.Apache.maven.cli.MavenCli.execute(MavenCli.Java:863)
    at org.Apache.maven.cli.MavenCli.doMain(MavenCli.Java:288)
    at org.Apache.maven.cli.MavenCli.main(MavenCli.Java:199)
    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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.Java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.Java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.Java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.Java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.Java:47)
Java.lang.RuntimeException: Error scanning entry META-INF/versions/9/org/Apache/logging/log4j/util/ProcessIdUtil.class from jar file:/Users/koraytugay/.m2/repository/org/Apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar
    at org.Eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.Java:913)
    at org.Eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.Java:831)
    at org.Eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.Java:159)
    at org.Eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.Java:542)
    at org.Eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.Java:607)
    at org.Eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.Java:536)
    at Java.lang.Thread.run(Thread.Java:745)
Caused by: Java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.Eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.Java:973)
    at org.Eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.Java:956)
    at org.Eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.Java:909)
    ... 6 more
Java.lang.RuntimeException: Error scanning entry META-INF/versions/9/org/Apache/logging/log4j/util/StackLocator.class from jar file:/Users/koraytugay/.m2/repository/org/Apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar
    at org.Eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.Java:913)
    at org.Eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.Java:831)
    at org.Eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.Java:159)
    at org.Eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.Java:542)
    at org.Eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.Java:607)
    at org.Eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.Java:536)
    at Java.lang.Thread.run(Thread.Java:745)
Caused by: Java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.Eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.Java:973)
    at org.Eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.Java:956)
    at org.Eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.Java:909)
    ... 6 more
[WARNING] !RequestLog
[INFO] Started [email protected]{HTTP/1.1}{0.0.0.0:8080}
[INFO] Started @2609ms
[INFO] Started Jetty Server

Wie kann ich Jetty mit log4j 2.9.1 zum Laufen bringen? Gibt es ein Problem in meiner Konfiguration oder ist dies ein Fehler in Jetty oder Log4J?

13
Koray Tugay

log4j 2.9 und höher sind Multi-Release-Gläser für Java 9.

Ihre Jetty-Version unterstützt das nicht. Aktualisieren Sie Jetty entweder auf eine mit Java 9 kompatible Version oder verwenden Sie log4j 2.8.x.

Siehe Jetty-Ausgabe Nr. 1797: JEP 238 - Multi-Release-JAR-Dateien brechen das Scannen von Bytecodes ab .

29
Andreas

Der folgende Fehler ist aufgetreten: com.ibm.ws.metadata.annotations.AnnotationException: Die Verarbeitung der Anmerkungen ist für die Klasse META-INF/versions/9/module-info.class fehlgeschlagen

Der obige Fehler tritt in WAS 9 auf, wenn wir versuchen, mehrere Anwendungen zu oft bereitzustellen oder die Bereitstellung aufzuheben. Der Server funktioniert nicht mehr richtig.

Als ich darauf gestoßen bin, habe ich alle Anwendungen auf dem Server deinstalliert. Und 2-3 mal neu gestartet. Nachdem der Server neu gestartet wurde, habe ich versucht, ihn erneut bereitzustellen, und die Anwendung hat wie erwartet funktioniert.

0
NavsTrend