これは、私のMavenプロジェクトにあるディレクトリレイアウトです。
.
├── pom.xml
└── src
└── main
├── Java
│ └── biz
│ └── tugay
│ └── web
│ └── servlet
│ └── MainServlet.Java
├── resources
│ └── log4j.properties
└── webapp
└── WEB-INF
└── web.xml
pom.xmlの関連部分は次のとおりです。
</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>
そして、ここに私の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>
最後に、これがlog4j.propertiesの外観です。
# 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
そのため、現在はすべて正常に動作し(mvn jetty:startでjettyを起動します)、「/」にアクセスするとコンソールに表示されます。
20:38:09.433 [qtp1503674351-26] ERROR biz.tugay.web.servlet.MainServlet - Serving request!
これはすべて大丈夫です。
<log4j.version>2.9.1</log4j.version>
後jetty:start私は得る:
[WARNING] Failed startup of context o.e.j.m.p.JettyWebAppContext@fb0d6fe{/,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 ServerConnector@42c81ca{HTTP/1.1}{0.0.0.0:8080}
[INFO] Started @2609ms
[INFO] Started Jetty Server
Log4j 2.9.1でjettyを動作させるにはどうすればよいですか?私の構成に問題はありますか、これはjettyまたはlog4jのバグですか?
log4j 2.9以降は multi-release jars for Java 9。
Jettyバージョンではサポートされていません。 JettyをJava 9互換バージョンにアップグレードするか、log4j 2.8.xを使用します。
Jetty issue#1797: JEP 238-Multi-Release JARファイルがバイトコードスキャンを中断する を参照してください。
次のエラーが発生しました:com.ibm.ws.metadata.annotations.AnnotationException:クラスの注釈処理が失敗しました:META-INF/versions/9/module-info.class
WAS 9では、複数のアプリケーションのデプロイとアンデプロイを何度も試行すると、上記のエラーが発生します。サーバーが誤動作します。
これに遭遇したとき、サーバー内のすべてのアプリケーションをアンインストールしました。そして、2〜3回再起動しました。サーバーを再起動したら、もう一度デプロイを試みましたが、アプリケーションは期待どおりに機能しました。