在v26之前的API级别上的SparkJava

时间:2018-05-17 17:04:28

标签: java android jetty httpserver spark-java

我使用SparkJava 2.3.0编写了一个使用Jetty 9.4.4.v20170414的简单代理。不幸的是,代理在Android 8(API 26)上运行良好,但它不适用于Android 7(API 24)。

我得到的线索是堆栈跟踪:

art  I  Rejecting re-init on previously-failed class java.lang.Class<org.eclipse.jetty.server.Response>: java.lang.NoSuchMethodError: No static method withInitial(Ljava/util/function/Supplier;)Ljava/lang/ThreadLocal; in class Ljava/lang/ThreadLocal; or its super classes (declaration of 'java.lang.ThreadLocal' appears in /system/framework/core-oj.jar)
     I    at void org.eclipse.jetty.server.Response.<clinit>() (Response.java:77)
     I    at void org.eclipse.jetty.server.HttpChannel.<init>(org.eclipse.jetty.server.Connector, org.eclipse.jetty.server.HttpConfiguration, org.eclipse.jetty.io.EndPoint, org.eclipse.jetty.server.HttpTransport) (HttpChannel.java:94)
     I    at void org.eclipse.jetty.server.HttpChannelOverHttp.<init>(org.eclipse.jetty.server.HttpConnection, org.eclipse.jetty.server.Connector, org.eclipse.jetty.server.HttpConfiguration, org.eclipse.jetty.io.EndPoint, org.eclipse.jetty.server.HttpTransport) (HttpChannelOverHttp.java:69)
     I    at org.eclipse.jetty.server.HttpChannelOverHttp org.eclipse.jetty.server.HttpConnection.newHttpChannel() (HttpConnection.java:127)
     I    at void org.eclipse.jetty.server.HttpConnection.<init>(org.eclipse.jetty.server.HttpConfiguration, org.eclipse.jetty.server.Connector, org.eclipse.jetty.io.EndPoint, org.eclipse.jetty.http.HttpCompliance, boolean) (HttpConnection.java:102)
     I    at org.eclipse.jetty.io.Connection org.eclipse.jetty.server.HttpConnectionFactory.newConnection(org.eclipse.jetty.server.Connector, org.eclipse.jetty.io.EndPoint) (HttpConnectionFactory.java:85)
     I    at org.eclipse.jetty.io.Connection org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(java.nio.channels.SelectableChannel, org.eclipse.jetty.io.EndPoint, java.lang.Object) (ServerConnector.java:482)
     I    at org.eclipse.jetty.io.EndPoint org.eclipse.jetty.io.ManagedSelector.createEndPoint(java.nio.channels.SelectableChannel, java.nio.channels.SelectionKey) (ManagedSelector.java:420)
     I    at org.eclipse.jetty.io.EndPoint org.eclipse.jetty.io.ManagedSelector.access$1600(org.eclipse.jetty.io.ManagedSelector, java.nio.channels.SelectableChannel, java.nio.channels.SelectionKey) (ManagedSelector.java:61)
     I    at void org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run() (ManagedSelector.java:599)
     I    at void org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(java.lang.Runnable) (QueuedThreadPool.java:672)
     I    at void org.eclipse.jetty.util.thread.QueuedThreadPool$2.run() (QueuedThreadPool.java:590)
     I    at void java.lang.Thread.run() (Thread.java:761)

看起来Google在API 26中添加了一个符合Java 8的方法ThreadLocal<S> ThreadLocal.withInitial (Supplier<? extends S> supplier)link),Jetty使用了这种方法。

有没有办法在26之前的Android API上使用SparkJava? 或者使用以前版本的Jetty?我试图降级SparkJava,但它仍在使用相当新版本的Jetty。

0 个答案:

没有答案