简体   繁体   English

Jersey 1.19.4 应用程序在 WEB-INF 中打包了所有依赖项,在 Tomcat 8.5 上为 jersey-server 抛出 FileNotFoundException

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

I have packaged these Jersey 1.19 libraries within my WEB-INF folder:我已将这些 Jersey 1.19 库打包到我的 WEB-INF 文件夹中:

  • jersey-client-1.19.4.jar jersey-client-1.19.4.jar
  • jersey-core-1.19.4.jar jersey-core-1.19.4.jar
  • jersey-json-1.19.4.jar jersey-json-1.19.4.jar
  • jersey-multipart-1.13.jar jersey-multipart-1.13.jar
  • jersey-server-1.19.4.jar jersey-server-1.19.4.jar
  • jersey-servlet-1.19.4.jar jersey-servlet-1.19.4.jar
  • jsr311-api-1.1.1.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.并通过打包战争的解压验证了它们的存在,并将其部署在 tomcat 8.5 上,它开始正常。

Though, When I run the traffic on this server I get the exception on server.init() :但是,当我在此服务器上运行流量时,我在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.此外,我有一个 Java 应用程序,它构建了这些 jersey 应用程序,并且已经使用了多年。 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.现在我正在添加对 Jersey 2 应用程序的支持,并将这些 war 文件与 tomcat(tomcat 8.5 与 jersey1 和 jersey2 战争)所需的依赖关系打包,与主应用程序中的 ZF48E94F82FFFCDC8C712AA1B37858 类中的 ZF48E94F82FFFCDC8C712AA1B37858 无关。

Check whether all the dependencies are there in pom.xml for Jersey or not.检查 pom.xml 中是否存在Jersey的所有依赖项。

Update project's pom.xml with these dependencies:使用以下依赖项更新项目的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>

After adding these dependencies, do mvn clean install/package on the project to create a fresh war and then, deploy it on the tomcat.添加这些依赖项后,对项目执行mvn clean install/package以创建新的战争,然后将其部署在 tomcat 上。

I think the problem will be solved.我认为问题会得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM