在Tomcat 8.5.11中运行Jersey API时,出现以下错误,导致API停止:
HTTP状态500-Servlet Jersey REST Service的Servlet.init()抛出异常
类型例外报告
Servlet Jersey REST Service的消息Servlet.init()抛出异常
描述服务器遇到内部错误,导致服务器无法满足此请求。
例外
javax.servlet.ServletException:用于Servlet Jersey REST Service的Servlet.init()引发了异常org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve。 java:79)org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)org.apache.coyote.http11.Http11Processor。服务(Http11Processor.java:783)org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:798)org.apache.tomcat.util。 net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1434)org.apache.tomcat.util.net.SocketProcessorBase。运行(SocketProcessorBase.java:49)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)org.apache.tomcat.util。 thread.TaskThread $ WrappingRunnable.run(TaskThread.java:61)java.lang.Thread.run(Thread.java:745)
根本原因
java.lang.IllegalStateException:找不到InjectionManagerFactory。org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:97)org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:89)org.glassfish.jersey.server.ApplicationHandler。 (ApplicationHandler.java:282)org.glassfish.jersey.servlet.WebComponent。(WebComponent.java:335)org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:178)org.glassfish.jersey.servlet。 ServletContainer.init(ServletContainer.java:370)javax.servlet.GenericServlet.init(GenericServlet.java:158)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)org.apache.catalina.valves。 ErrorReportValve.invoke(ErrorReportValve.java:79)org.apache.catalina.valves。
应用程序使用以下gradle依赖项进行构建:
dependencies {
compile (
// REST
"org.glassfish.jersey.containers:jersey-container-servlet:2.+",
"javax.servlet:javax.servlet-api:4.+",
// REST Token
"org.bitbucket.b_c:jose4j:0.+",
// MongoDB
"org.hibernate.ogm:hibernate-ogm-bom:5.+",
"org.hibernate.ogm:hibernate-ogm-infinispan:5.+",
"org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.+",
"org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.+",
"org.jboss.narayana.jta:narayana-jta:5.+",
"org.jboss:jboss-transaction-spi:7.+",
"log4j:log4j:1.+",
"org.hibernate.ogm:hibernate-ogm-mongodb:5.+",
"org.bouncycastle:bcprov-jdk15on:1.+"
) }
此下载jersey-common-2.26-b04.jar
内容包含中缺少的类/org/glassfish/jersey/internal/inject/InjectionManagerFactory
。jar文件被部署到下面的Tomcat文件夹中WEB-INF/lib
这里有什么问题?gradle脚本在最近几个月使用相同的Tomcat版本。