Spring Boot (2.0.0.BUILD-SNAPSHOT) 应用程序无法从 Jetty 启动



我想启动一个 Spring Boot 应用程序,但由于以下原因无法启动:

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-07-05 15:51:19.216 ERROR 10080 --- [           main] o.s.boot.SpringApplication               : Application startup failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:137) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at io.sc.pps.Application.main(Application.java:42) [main/:na]
Caused by: java.lang.ExceptionInInitializerError: null
at org.eclipse.jetty.servlet.ServletContextHandler.newSessionHandler(ServletContextHandler.java:296) ~[jetty-servlet-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.servlet.ServletContextHandler.getSessionHandler(ServletContextHandler.java:391) ~[jetty-servlet-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.servlet.ServletContextHandler.relinkHandlers(ServletContextHandler.java:199) ~[jetty-servlet-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:171) ~[jetty-servlet-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.webapp.WebAppContext.<init>(WebAppContext.java:289) ~[jetty-webapp-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.webapp.WebAppContext.<init>(WebAppContext.java:211) ~[jetty-webapp-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.springframework.boot.web.embedded.jetty.JettyEmbeddedWebAppContext.<init>(JettyEmbeddedWebAppContext.java:28) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory.getWebServer(JettyServletWebServerFactory.java:155) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:161) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:134) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
... 8 common frames omitted
Caused by: java.lang.SecurityException: class "javax.servlet.http.HttpSessionIdListener"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:898) ~[na:1.8.0_131]
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:668) ~[na:1.8.0_131]
at java.lang.ClassLoader.defineClass(ClassLoader.java:761) ~[na:1.8.0_131]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_131]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_131]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_131]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_131]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_131]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_131]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_131]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_131]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131]
at org.eclipse.jetty.server.session.SessionHandler.<clinit>(SessionHandler.java:140) ~[jetty-server-9.4.6.v20170531.jar:9.4.6.v20170531]
... 18 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:52640', transport: 'socket'
Process finished with exit code 1

我以前从未见过这样的错误,研究它不会导致任何可行的解决方案。

有人知道这里发生了什么吗?

更新

我的 Gradle 依赖项:

repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "http://download.osgeo.org/webdav/geotool" }
maven { url "http://www.hibernatespatial.org/repository" }
maven { url "http://repo.boundlessgeo.com/main/" }
maven { url "http://www.datanucleus.org/downloads/maven2/" }
maven { url "http://oss.jfrog.org/artifactory/oss-snapshot-local/" }
}
dependencyManagement {
dependencies {
dependencySet (group: 'org.hibernate', version: '5.2.8.Final') {
entry 'hibernate-core'
entry 'hibernate-entitymanager'
entry 'hibernate-spatial'
}
dependency (group: 'io.prometheus', name: 'simpleclient_spring_boot', version: '0.0.21')
dependencySet (group: 'io.github.resilience4j', version: '0.9.0-SNAPSHOT') {
entry 'resilience4j-spring-boot'
entry 'resilience4j-metrics'
entry 'resilience4j-prometheus'
}
dependencySet (group: 'org.apache.ignite', version: '1.9.0') {
entry 'ignite-core'
entry 'ignite-spring'
entry 'ignite-rest-http'
}
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-hateoas')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-jetty')
compile('org.springframework.boot:spring-boot-starter-webflux')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('io.prometheus:simpleclient_spring_boot')
compile('io.github.resilience4j:resilience4j-spring-boot') {
exclude group: 'org.slf4j'
}
compile('io.github.resilience4j:resilience4j-metrics') {
exclude group: 'org.slf4j'
}
compile('io.github.resilience4j:resilience4j-prometheus') {
exclude group: 'org.slf4j'
}
compile('org.apache.ignite:ignite-core')
compile('org.apache.ignite:ignite-spring')
//    compile('org.apache.ignite:ignite-rest-http')
compile('com.h2database:h2')
compile(group: 'org.apache.hive', name: 'hive-jdbc', version: '2.1.1') {
exclude group: 'org.slf4j'
}
compile(group: 'org.springframework.data', name: 'spring-data-hadoop', version: '2.4.0.RELEASE')
compile(group: 'org.springframework.data', name: 'spring-data-hadoop-config', version: '2.4.0.RELEASE')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('junit:junit')
}

原因:java.lang.SecurityException: 类 "javax.servlet.http.HttpSessionIdListener" 的签名者信息与同一包中其他类的签名者信息不匹配

这意味着您的类路径中有多个javax.servlet.http.HttpSessionIdListener(并且其中一个或多个位于已签名的 jar 文件中)。

清理你的依赖关系,确保你只有一个servlet-api jar。

由于您使用的是 Jetty 9.4.6,因此central.maven.org上的 servlet-api 3.1 jar 坐标是 ...

compile 'javax.servlet:javax.servlet-api:3.1.0'

如何列出所有带有类的罐子

创建一个类以转储您感兴趣的类的位置。 这是作为 junit 测试用例创建的,因此它可以在与您的项目相同的 gradle 依赖项中运行。

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import javax.servlet.http.HttpSessionIdListener;
import org.junit.Test;
public class ClasspathTest
{
@Test
public void testJavaServlet() throws IOException
{
ClassLoader cl = this.getClass().getClassLoader();
String classAsResource = HttpSessionIdListener.class.getName().replace('.','/') + ".class";
Enumeration<URL> urls = cl.getResources(classAsResource);
System.out.printf("Looking for: %s%n",classAsResource);
while (urls.hasMoreElements())
{
URL url = urls.nextElement();
System.out.printf("Found: %s%n",url.toExternalForm());
}
}
}

最新更新