Jersey 1.19.4 application with packaged all dependencies in WEB-INF throws FileNotFoundException for jersey-server on Tomcat 8.5

huangapple go评论135阅读模式
英文:

Jersey 1.19.4 application with packaged all dependencies in WEB-INF throws FileNotFoundException for jersey-server on Tomcat 8.5

问题

我已将这些 Jersey 1.19 库打包到我的 WEB-INF 文件夹中:

  • jersey-client-1.19.4.jar
  • jersey-core-1.19.4.jar
  • jersey-json-1.19.4.jar
  • jersey-multipart-1.13.jar
  • jersey-server-1.19.4.jar
  • jersey-servlet-1.19.4.jar
  • jsr311-api-1.1.1.jar

并通过解压打包的 WAR 文件验证了它们的存在,并将其部署到 Tomcat 8.5 上,它可以正常启动。

但是,当我在此服务器上运行流量时,我在 server.init() 上收到异常:

com.sun.jersey.spi.service.ServiceConfigurationError: com.sun.jersey.spi.container.WebApplicationProvider: : java.io.FileNotFoundException: JAR entry WEB-INF/lib/jersey-server-1.19.4.jar

此外,
我有一个构建这些 Jersey 应用程序的 Java 应用程序,多年来一直在运行。现在我也要添加对 Jersey 2 应用程序的支持,并将这些 WAR 文件与所需的依赖项一起打包到 Tomcat 上(Tomcat 8.5 上有 Jersey 1 和 Jersey 2 的 WAR 文件),主应用程序的类路径中没有 Jersey 相关的内容。

英文:

I have packaged these Jersey 1.19 libraries within my WEB-INF folder:

  • jersey-client-1.19.4.jar
  • jersey-core-1.19.4.jar
  • jersey-json-1.19.4.jar
  • jersey-multipart-1.13.jar
  • jersey-server-1.19.4.jar
  • jersey-servlet-1.19.4.jar
  • jsr311-api-1.1.1.jar

and have verified their presence with untar of the packaged war, and deployed it on tomcat 8.5 and it starts fine.

Though, When I run the traffic on this server I get the exception on server.init():

com.sun.jersey.spi.service.ServiceConfigurationError: com.sun.jersey.spi.container.WebApplicationProvider: : java.io.FileNotFoundException: JAR entry WEB-INF/lib/jersey-server-1.19.4.jar

Additionally,
I have a Java application that builds these jersey apps and it did for years. now I am adding support to Jersey 2 apps as well and packaging these war files with required dependencies on tomcat (tomcat 8.5 with jersey1 and jersey2 wars), nothing about jersey in the classpath of the main app.

答案1

得分: 2

检查 pom.xml 中是否包含 Jersey 所需的所有依赖项。

更新项目的 pom.xml,添加以下依赖项:

<dependencies>
   <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-client</artifactId>
      <version>1.19.4</version>
   </dependency>
   <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-core</artifactId>
      <version>1.19.4</version>
   </dependency>
   <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-json</artifactId>
      <version>1.19.4</version>
   </dependency>
   <dependency>
      <groupId>com.sun.jersey.contribs</groupId>
      <artifactId>jersey-multipart</artifactId>
      <version>1.19.4</version>
   </dependency>
   <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-server</artifactId>
      <version>1.19.4</version>
   </dependency>
   <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-servlet</artifactId>
      <version>1.19.4</version>
   </dependency>
   <dependency>
      <groupId>javax.ws.rs</groupId>
      <artifactId>jsr311-api</artifactId>
      <version>1.1.1</version>
   </dependency>
</dependencies>

添加这些依赖项后,在项目上运行 mvn clean install/package 创建一个新的 war 文件,然后将其部署到 Tomcat 上。

我认为问题将会得到解决。

英文:

Check whether all the dependencies are there in pom.xml for Jersey or not.

Update project's pom.xml with these dependencies :

&lt;dependencies&gt;
   &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
      &lt;version&gt;1.19.4&lt;/version&gt;
   &lt;/dependency&gt;
   &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-core&lt;/artifactId&gt;
      &lt;version&gt;1.19.4&lt;/version&gt;
   &lt;/dependency&gt;
   &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
      &lt;version&gt;1.19.4&lt;/version&gt;
   &lt;/dependency&gt;
   &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-multipart&lt;/artifactId&gt;
      &lt;version&gt;1.19.4&lt;/version&gt;
   &lt;/dependency&gt;
   &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
      &lt;version&gt;1.19.4&lt;/version&gt;
   &lt;/dependency&gt;
   &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-servlet&lt;/artifactId&gt;
      &lt;version&gt;1.19.4&lt;/version&gt;
   &lt;/dependency&gt;
   &lt;dependency&gt;
      &lt;groupId&gt;javax.ws.rs&lt;/groupId&gt;
      &lt;artifactId&gt;jsr311-api&lt;/artifactId&gt;
      &lt;version&gt;1.1.1&lt;/version&gt;
   &lt;/dependency&gt;
&lt;/dependencies&gt;

After adding these dependencies, do mvn clean install/package on the project to create a fresh war and then, deploy it on the tomcat.

I think the problem will be solved.

huangapple
  • 本文由 发表于 2020年7月22日 19:12:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/63032901.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定