I am receiving below error while running my jersey API
in tomcat 8.5.11
which is causing my API to stop -:
在tomcat 8.5.11中运行我的jersey API时,我收到以下错误,这导致我的API停止-:
HTTP Status 500 - Servlet.init() for servlet Jersey REST Service threw exception
HTTP状态500—servlet Jersey REST服务的servlet .init()抛出异常
type Exception report
类型异常报告
message Servlet.init() for servlet Jersey REST Service threw exception
用于servlet Jersey REST服务的消息servlet .init()抛出异常
description The server encountered an internal error that prevented it from fulfilling this request.
描述服务器遇到了一个内部错误,导致它无法执行此请求。
exception
异常
javax.servlet.ServletException: Servlet.init() for servlet Jersey REST Service threw exception 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.service(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.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745)
javax.servlet。ServletException:servlet Jersey REST服务的servlet .init()用于抛出异常org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java: authenticatorbase . 474) org.apache.catalina.valves. errorreportve.com .invoke .invoke .invoke .invoke .invoke .java . php . php .abstractprocess (abstractprotocol . abstractprotocol . abstractprotocol $ connectionhandler.net/abstractprotocol $ connectionhandler.html) .process(AbstractProtocol.java:798) . . . . . .org.apache.tomcat.util.threads.TaskThread WrappingRunnable.run美元(TaskThread.java:61)java.lang.Thread.run(Thread.java:745)
root cause
根本原因
java.lang.IllegalStateException: InjectionManagerFactory not found. 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.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) org.apache.coyote.http11.Http11Processor.service(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.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745)
. lang。IllegalStateException:InjectionManagerFactory没有找到。java .servlet. genericservlet.init (GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke .invoke . (AuthenticatorBase.java:474) org.apache.c inache.c。进程(AbstractProtocol.java:798) . apachtprocessorlightl .java:66) org.apache. coyotel . abstractprotocol $ConnectionHandler.process(AbstractProtocol.java:798)org.apache.tomcat.util.threads.TaskThread WrappingRunnable.run美元(TaskThread.java:61)java.lang.Thread.run(Thread.java:745)
The application is build with the following dependencies with 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.+"
) }
This downloads jersey-common-2.26-b04.jar
which contains the missing class under /org/glassfish/jersey/internal/inject/InjectionManagerFactory
. The jar file is deployed into the tomcat
folder under WEB-INF/lib
这个下载jersey -通用- 2.26 -当您。jar包含/ /org/glassfish/jersey/internal/inject/InjectionManagerFactory中缺失的类。jar文件被部署到WEB-INF/lib下的tomcat文件夹中
What can be wrong here? The gradle
script worked the last few month with the same tomcat
version.
这里有什么问题吗?在过去的几个月中,gradle脚本使用了相同的tomcat版本。
12 个解决方案
#1
18
I have the same problem, after downgrading to the version deployed in march (2.26-b03) everything is back to normal, hope it helps
我也有同样的问题,在降级到3月份部署的版本(2.26-b03)之后,一切都恢复了正常,希望这能有所帮助
#2
107
Add this dependency:
添加这种依赖性:
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
cf. https://*.com/a/44536542/1070215
参见https://*.com/a/44536542/1070215
#3
70
Jersey 2.26 and newer are not backward compatible with older versions. The reason behind that has been stated in the release notes:
Jersey 2.26和更新并不向后兼容旧版本。这背后的原因已在发布说明中说明:
Unfortunately, there was a need to make backwards incompatible changes in 2.26. Concretely jersey-proprietary reactive client API is completely gone and cannot be supported any longer - it conflicts with what was introduced in JAX-RS 2.1 (that's the price for Jersey being "spec playground..").
不幸的是,在2.26中需要进行向后不兼容的更改。具体来说,jerchy - private反应式客户端API已经完全消失,再也不能被支持了——它与JAX-RS 2.1中引入的内容相冲突(这是Jersey作为“spec游乐场”的代价)。
Another bigger change in Jersey code is attempt to make Jersey core independent of any specific injection framework. As you might now, Jersey 2.x is (was!) pretty tightly dependent on HK2, which sometimes causes issues (esp. when running on other injection containers. Jersey now defines it's own injection facade, which, when implemented properly, replaces all internal Jersey injection.
Jersey代码的另一个更大的变化是试图使Jersey core独立于任何特定的注入框架。就像你现在看到的,新泽西2号。x非常依赖于HK2,这有时会导致问题(尤其是在其他注入容器上运行时)。Jersey现在定义了它自己的注入facade,如果实现得当,它将替换所有内部的Jersey注入。
As for now one should use the following dependencies:
就目前而言,应该使用以下依赖项:
Maven
Maven
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.26</version>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.26</version>
Gradle
Gradle
compile 'org.glassfish.jersey.core:jersey-common:2.26'
compile 'org.glassfish.jersey.inject:jersey-hk2:2.26'
#4
8
Choose which DI to inject stuff into Jersey:
选择将哪种DI注入Jersey:
Spring 4:
春天4:
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring4</artifactId>
</dependency>
Spring 3:
春天3:
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
</dependency>
HK2:
HK2:
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
#5
6
Downgrade the jersey version in pom.xml change the tag 2.26-b04 to 2.26-b03
降低新泽西版的pom。xml将标记2.26-b04更改为2.26-b03
#6
2
I have the same problem. I added the latest jersey-hk2 dependency and it works like a charm.
我也有同样的问题。我添加了最新的jercy -hk2依赖项,它工作起来像一个魅力。
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
#7
2
The only way I could solve it was via:
我唯一能解决的办法是:
org.glassfish.jersey.core jersey-server ${jersey-2-version}
org.glassfish.jersey。核心jersey-server $ { jersey-2-version }
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey-2-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey-2-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>${jersey-2-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>${jersey-2-version}</version>
</dependency>
So, only if I added jersey-container-servlet
and jersey-hk2
would it run without errors
所以,只有我添加了jerchy -container-servlet和jerchy -hk2,它才能正常运行
#8
2
It seems this does not work with 2.26. Either downgrade the version or add following to your pom :
这似乎对2.26不起作用。降级版本或添加以下到您的pom:
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.26</version>
</dependency>
#9
1
As far as I can see dependencies have changed between 2.26-b03 and 2.26-b04 (HK2 was moved to from compile to testCompile)... there might be some change in the jersey dependencies that has not been completed yet (or which lead to a bug).
在我看来,依赖项在2.26-b03和2.26-b04之间发生了变化(HK2从编译转移到testCompile)……在尚未完成的jersey依赖项中可能会有一些更改(或者会导致错误)。
However, right now the simple solution is to stick to an older version :-)
然而,目前最简单的解决办法是坚持使用旧版本:-)
#10
0
Yes, it's from the latest release from friday 19th may. I just changed my version in the Maven to an older one, and it's works perfect again.
是的,这是5月19日星期五的最新版本。我刚刚将Maven中的版本更改为旧版本,它再次运行良好。
#11
0
Here is the new dependency (August 2017)
这是新属地(2017年8月)
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.0-m03</version>
</dependency>
#12
0
I had the same issue with jersey version 2.26. I used the older version(v.2.16) and now its working fine.
我对jersey 2.26也有同样的问题。我使用了旧版本(v2.16),现在运行良好。
#1
18
I have the same problem, after downgrading to the version deployed in march (2.26-b03) everything is back to normal, hope it helps
我也有同样的问题,在降级到3月份部署的版本(2.26-b03)之后,一切都恢复了正常,希望这能有所帮助
#2
107
Add this dependency:
添加这种依赖性:
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
cf. https://*.com/a/44536542/1070215
参见https://*.com/a/44536542/1070215
#3
70
Jersey 2.26 and newer are not backward compatible with older versions. The reason behind that has been stated in the release notes:
Jersey 2.26和更新并不向后兼容旧版本。这背后的原因已在发布说明中说明:
Unfortunately, there was a need to make backwards incompatible changes in 2.26. Concretely jersey-proprietary reactive client API is completely gone and cannot be supported any longer - it conflicts with what was introduced in JAX-RS 2.1 (that's the price for Jersey being "spec playground..").
不幸的是,在2.26中需要进行向后不兼容的更改。具体来说,jerchy - private反应式客户端API已经完全消失,再也不能被支持了——它与JAX-RS 2.1中引入的内容相冲突(这是Jersey作为“spec游乐场”的代价)。
Another bigger change in Jersey code is attempt to make Jersey core independent of any specific injection framework. As you might now, Jersey 2.x is (was!) pretty tightly dependent on HK2, which sometimes causes issues (esp. when running on other injection containers. Jersey now defines it's own injection facade, which, when implemented properly, replaces all internal Jersey injection.
Jersey代码的另一个更大的变化是试图使Jersey core独立于任何特定的注入框架。就像你现在看到的,新泽西2号。x非常依赖于HK2,这有时会导致问题(尤其是在其他注入容器上运行时)。Jersey现在定义了它自己的注入facade,如果实现得当,它将替换所有内部的Jersey注入。
As for now one should use the following dependencies:
就目前而言,应该使用以下依赖项:
Maven
Maven
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.26</version>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.26</version>
Gradle
Gradle
compile 'org.glassfish.jersey.core:jersey-common:2.26'
compile 'org.glassfish.jersey.inject:jersey-hk2:2.26'
#4
8
Choose which DI to inject stuff into Jersey:
选择将哪种DI注入Jersey:
Spring 4:
春天4:
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring4</artifactId>
</dependency>
Spring 3:
春天3:
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
</dependency>
HK2:
HK2:
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
#5
6
Downgrade the jersey version in pom.xml change the tag 2.26-b04 to 2.26-b03
降低新泽西版的pom。xml将标记2.26-b04更改为2.26-b03
#6
2
I have the same problem. I added the latest jersey-hk2 dependency and it works like a charm.
我也有同样的问题。我添加了最新的jercy -hk2依赖项,它工作起来像一个魅力。
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
#7
2
The only way I could solve it was via:
我唯一能解决的办法是:
org.glassfish.jersey.core jersey-server ${jersey-2-version}
org.glassfish.jersey。核心jersey-server $ { jersey-2-version }
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey-2-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey-2-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>${jersey-2-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>${jersey-2-version}</version>
</dependency>
So, only if I added jersey-container-servlet
and jersey-hk2
would it run without errors
所以,只有我添加了jerchy -container-servlet和jerchy -hk2,它才能正常运行
#8
2
It seems this does not work with 2.26. Either downgrade the version or add following to your pom :
这似乎对2.26不起作用。降级版本或添加以下到您的pom:
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.26</version>
</dependency>
#9
1
As far as I can see dependencies have changed between 2.26-b03 and 2.26-b04 (HK2 was moved to from compile to testCompile)... there might be some change in the jersey dependencies that has not been completed yet (or which lead to a bug).
在我看来,依赖项在2.26-b03和2.26-b04之间发生了变化(HK2从编译转移到testCompile)……在尚未完成的jersey依赖项中可能会有一些更改(或者会导致错误)。
However, right now the simple solution is to stick to an older version :-)
然而,目前最简单的解决办法是坚持使用旧版本:-)
#10
0
Yes, it's from the latest release from friday 19th may. I just changed my version in the Maven to an older one, and it's works perfect again.
是的,这是5月19日星期五的最新版本。我刚刚将Maven中的版本更改为旧版本,它再次运行良好。
#11
0
Here is the new dependency (August 2017)
这是新属地(2017年8月)
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.0-m03</version>
</dependency>
#12
0
I had the same issue with jersey version 2.26. I used the older version(v.2.16) and now its working fine.
我对jersey 2.26也有同样的问题。我使用了旧版本(v2.16),现在运行良好。