英文:
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 :
<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.
I think the problem will be solved.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论