SparkJava Exception java.lang.NoClassDefFoundError: org/ecli



用于Spark-java的代码(用于Spring Boot)

public static void main(String[] args) {
    Spark.port(8080);
    Spark.webSocket("/chat", ChatWebSocketHandler.class);
    Spark.init();

I get exception and stop

Exception in thread "Thread-2" java.lang.NoClassDefFoundError: org/eclipse/jetty/websocket/server/pathmap/PathSpec
    at spark.embeddedserver.jetty.EmbeddedJettyServer.ignite(EmbeddedJettyServer.java:105)
    at spark.Service.lambda$init$0(Service.java:349)
    at spark.Service$$Lambda$7/1663488386.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.server.pathmap.PathSpec
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 4 more
对于Maven,我使用
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.RELEASE</version>
</parent>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>

    <dependency>
        <groupId>com.sparkjava</groupId>
        <artifactId>spark-core</artifactId>
        <version>2.5</version>
    </dependency>

,我明白了jetty-server-9.3.11.v20160721.jar,websocket-server-9.3.11.v20160721.jar和许多其他依赖

相同的工作在演示https://github.com/tipsy/spark-websocket

问题是Spring Boot重新定义了要使用的较新的Jetty版本。

解决

<properties>
    ...
    <jetty.version>9.3.6.v20151106</jetty.version> <!-- redefine for sparkjava 2.5 vs 9.3.11.v20160721 in spring-boot-dependencies -->
</properties>    

相关内容

  • 没有找到相关文章

最新更新