RequestLogCollection Jetty 9.3.9 中的 NullPointerException
NullPointerException in RequestLogCollection Jetty 9.3.9
我在我的嵌入式应用程序中使用 Jetty 9.3.9.v20160517,并且我已经使用 jetty-requestlog.xml
配置日志记录,如下所示:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<!-- =============================================================== -->
<!-- Configure the Jetty Request Log -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Configure Request Log for Server -->
<!-- (Use RequestLogHandler for a context specific RequestLog -->
<!-- =========================================================== -->
<Set name="RequestLog">
<New id="RequestLog" class="org.eclipse.jetty.server.AsyncNCSARequestLog">
<Set name="filename"><Property name="jetty.base" default="." /><Property>
<Name>jetty.requestlog.filePath</Name>
<Deprecated>requestlog.filename</Deprecated>
<Default><Property name="jetty.requestlog.dir" default="/logs"/>/yyyy_mm_dd.request.log</Default>
</Property>
</Set>
<Set name="filenameDateFormat"><Property name="jetty.requestlog.filenameDateFormat" deprecated="requestlog.filenameDateFormat" default="yyyy_MM_dd"/></Set>
<Set name="retainDays"><Property name="jetty.requestlog.retainDays" deprecated="requestlog.retain" default="90"/></Set>
<Set name="append"><Property name="jetty.requestlog.append" deprecated="requestlog.append" default="true"/></Set>
<Set name="extended"><Property name="jetty.requestlog.extended" deprecated="requestlog.extended" default="false"/></Set>
<Set name="logCookies"><Property name="jetty.requestlog.cookies" deprecated="requestlog.cookies" default="false"/></Set>
<Set name="LogTimeZone"><Property name="jetty.requestlog.timezone" deprecated="requestlog.timezone" default="GMT"/></Set>
</New>
</Set>
</Configure>
然而,在运行时,当 Jetty 实际尝试记录任何内容时,我每次向服务器发出请求时都会收到以下 NPE,即使日志似乎确实已写入 $jetty.base/logs/2016_06_15.request.log
.
2016-06-15 22:19:23,302 [eXistThread-29] WARN (HttpChannel.java [handle]:479) - //localhost:8080/exist/apps/dashboard/modules/get-icon.xql?package=http://exist-db.org/apps/eXide
java.lang.NullPointerException
at org.eclipse.jetty.server.RequestLogCollection.log(RequestLogCollection.java:44) ~[jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.HttpChannel.onCompleted(HttpChannel.java:620) ~[jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:453) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:253) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.io.SelectChannelEndPoint.run(SelectChannelEndPoint.java:93) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:589) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_92]
那么...是什么导致了这些 NPE,请问我该如何解决它们?
您的 XML load order is bad(请参阅您的来源中的 etc/enabled-jetty-config
)
.
您可以通过以下方式了解此订单的运作方式。
使用 jetty-distribution
:-)
# Use a new empty base
$ cd /path/to/mybase
# Lets add the modules into this base
$ java -jar /path/to/jetty-dist/start.jar --add-to-start=annotations,deploy,https,gzip,jmx,requestlog
INFO: server initialised (transitively) in ${jetty.base}/start.ini
INFO: gzip initialised in ${jetty.base}/start.ini
INFO: jmx initialised in ${jetty.base}/start.ini
INFO: requestlog initialised in ${jetty.base}/start.ini
INFO: ssl initialised (transitively) in ${jetty.base}/start.ini
INFO: https initialised in ${jetty.base}/start.ini
INFO: deploy initialised in ${jetty.base}/start.ini
INFO: annotations initialised in ${jetty.base}/start.ini
MKDIR: ${jetty.base}/logs
DOWNLOAD: https://raw.githubusercontent.com/eclipse/jetty.project/master/jetty-server/src/test/config/etc/keystore?id=master to ${jetty.base}/etc/keystore
MKDIR: ${jetty.base}/webapps
INFO: Base directory was modified
# Lets ask the jetty-distribution what its XML load order is
java -jar /path/to/jetty-dist/start.jar --list-config
...(snip lots of output)...
Jetty Active XMLs:
------------------
${jetty.home}/etc/jetty.xml
${jetty.home}/etc/jetty-gzip.xml
${jetty.home}/etc/jetty-jmx.xml
${jetty.home}/etc/jetty-requestlog.xml
${jetty.home}/etc/jetty-ssl.xml
${jetty.home}/etc/jetty-ssl-context.xml
${jetty.home}/etc/jetty-https.xml
${jetty.home}/etc/jetty-deploy.xml
${jetty.home}/etc/jetty-plus.xml
${jetty.home}/etc/jetty-annotations.xml
注意:此加载顺序可以(并且确实!)在不同的 Jetty 版本之间发生变化。
不要依赖于这是 Jetty 未来所有版本的唯一真正加载顺序。您要么必须实施相同的 start.jar
模块逻辑,要么在每次升级项目时重做 jetty-distribution/start.jar --list-config
。
WARNING: Don't do this, don't mix jetty-distribution
and embedded-jetty
, you are just creating lots of extra work for yourself, increasing your maintenance tasks, etc. Use embedded-jetty
*or* jetty-distribution
directly.
我在我的嵌入式应用程序中使用 Jetty 9.3.9.v20160517,并且我已经使用 jetty-requestlog.xml
配置日志记录,如下所示:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<!-- =============================================================== -->
<!-- Configure the Jetty Request Log -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Configure Request Log for Server -->
<!-- (Use RequestLogHandler for a context specific RequestLog -->
<!-- =========================================================== -->
<Set name="RequestLog">
<New id="RequestLog" class="org.eclipse.jetty.server.AsyncNCSARequestLog">
<Set name="filename"><Property name="jetty.base" default="." /><Property>
<Name>jetty.requestlog.filePath</Name>
<Deprecated>requestlog.filename</Deprecated>
<Default><Property name="jetty.requestlog.dir" default="/logs"/>/yyyy_mm_dd.request.log</Default>
</Property>
</Set>
<Set name="filenameDateFormat"><Property name="jetty.requestlog.filenameDateFormat" deprecated="requestlog.filenameDateFormat" default="yyyy_MM_dd"/></Set>
<Set name="retainDays"><Property name="jetty.requestlog.retainDays" deprecated="requestlog.retain" default="90"/></Set>
<Set name="append"><Property name="jetty.requestlog.append" deprecated="requestlog.append" default="true"/></Set>
<Set name="extended"><Property name="jetty.requestlog.extended" deprecated="requestlog.extended" default="false"/></Set>
<Set name="logCookies"><Property name="jetty.requestlog.cookies" deprecated="requestlog.cookies" default="false"/></Set>
<Set name="LogTimeZone"><Property name="jetty.requestlog.timezone" deprecated="requestlog.timezone" default="GMT"/></Set>
</New>
</Set>
</Configure>
然而,在运行时,当 Jetty 实际尝试记录任何内容时,我每次向服务器发出请求时都会收到以下 NPE,即使日志似乎确实已写入 $jetty.base/logs/2016_06_15.request.log
.
2016-06-15 22:19:23,302 [eXistThread-29] WARN (HttpChannel.java [handle]:479) - //localhost:8080/exist/apps/dashboard/modules/get-icon.xql?package=http://exist-db.org/apps/eXide
java.lang.NullPointerException
at org.eclipse.jetty.server.RequestLogCollection.log(RequestLogCollection.java:44) ~[jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.HttpChannel.onCompleted(HttpChannel.java:620) ~[jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:453) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:253) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.io.SelectChannelEndPoint.run(SelectChannelEndPoint.java:93) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:589) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_92]
那么...是什么导致了这些 NPE,请问我该如何解决它们?
您的 XML load order is bad(请参阅您的来源中的 etc/enabled-jetty-config
)
您可以通过以下方式了解此订单的运作方式。
使用 jetty-distribution
:-)
# Use a new empty base
$ cd /path/to/mybase
# Lets add the modules into this base
$ java -jar /path/to/jetty-dist/start.jar --add-to-start=annotations,deploy,https,gzip,jmx,requestlog
INFO: server initialised (transitively) in ${jetty.base}/start.ini
INFO: gzip initialised in ${jetty.base}/start.ini
INFO: jmx initialised in ${jetty.base}/start.ini
INFO: requestlog initialised in ${jetty.base}/start.ini
INFO: ssl initialised (transitively) in ${jetty.base}/start.ini
INFO: https initialised in ${jetty.base}/start.ini
INFO: deploy initialised in ${jetty.base}/start.ini
INFO: annotations initialised in ${jetty.base}/start.ini
MKDIR: ${jetty.base}/logs
DOWNLOAD: https://raw.githubusercontent.com/eclipse/jetty.project/master/jetty-server/src/test/config/etc/keystore?id=master to ${jetty.base}/etc/keystore
MKDIR: ${jetty.base}/webapps
INFO: Base directory was modified
# Lets ask the jetty-distribution what its XML load order is
java -jar /path/to/jetty-dist/start.jar --list-config
...(snip lots of output)...
Jetty Active XMLs:
------------------
${jetty.home}/etc/jetty.xml
${jetty.home}/etc/jetty-gzip.xml
${jetty.home}/etc/jetty-jmx.xml
${jetty.home}/etc/jetty-requestlog.xml
${jetty.home}/etc/jetty-ssl.xml
${jetty.home}/etc/jetty-ssl-context.xml
${jetty.home}/etc/jetty-https.xml
${jetty.home}/etc/jetty-deploy.xml
${jetty.home}/etc/jetty-plus.xml
${jetty.home}/etc/jetty-annotations.xml
注意:此加载顺序可以(并且确实!)在不同的 Jetty 版本之间发生变化。
不要依赖于这是 Jetty 未来所有版本的唯一真正加载顺序。您要么必须实施相同的 start.jar
模块逻辑,要么在每次升级项目时重做 jetty-distribution/start.jar --list-config
。
WARNING: Don't do this, don't mix
jetty-distribution
andembedded-jetty
, you are just creating lots of extra work for yourself, increasing your maintenance tasks, etc. Useembedded-jetty
*or*jetty-distribution
directly.