- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我通读了大量与此问题相关的帖子,但无法获得任何帮助。
错误如果有人可以帮助我,我将不胜感激。
这就是我的 POM 和 Web 的样子。我尝试将所需的 war 文件复制到 C:\appache tomcat 7 但没有成功。即使在 eclipse 中部署它也会给我同样的错误。
网页版 enter image description here
POM.xml:-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tutorialacademy.rest</groupId>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>helloworld Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-apache-client</artifactId>
<version>1.19</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
最佳答案
异常(exception)情况下,它看起来像 com.sun.jersey.spi.container.servlet.ServletContainer
类在您的类路径中不可用。
请注意,Jersey 1.x 和 Jersey 2.x 使用不同的包名称:
com.sun.jersey
org.glassfish.jersey
因此,我了解到您正在使用 Jersey 1.x。
要使用 Jersey 1.x,您需要在 pom.xml
中添加以下依赖项:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
要阅读更多关于 Jersey 1.x 依赖项的信息,请查看 documentation .
您可以在Maven Repository中查看最新版本的jersey-server
artifactId
.
如果您想使用Jersey 2.x,您必须将以下依赖项添加到您的pom.xml
:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- if your container implements Servlet API older than 3.0,
use "jersey-container-servlet-core" -->
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.1</version>
</dependency>
您可以在Maven Repository中查看最新版本的jersey-container-servlet
artifactId
.
在 documentation 中阅读更多关于 Jersey 2.x 依赖项的信息.
如果可以,我建议使用 Jersey 2.x 而不是 Jersey 1.x。
为此,请使用以下 pom.xml
:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tutorialacademy.rest</groupId>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Hello World</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- if your container implements Servlet API older than 3.0,
use "jersey-container-servlet-core" -->
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
以及以下 web.xml
:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
</web-app>
关于eclipse - 严重 : Servlet/JAXRS-HelloWorld threw load() exception java. lang.ClassNotFoundException : com. sun.jersey.spi.container.servlet.ServletContainer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33608943/
我的 iPad 应用程序一直在日志中显示此消息...... : ImageIO: CreateMetadataFromXMPBufferInternal Threw error #203 (Dupl
我正在使用 sinon.JS 编写简单的单元测试。被测试的代码有一些类型检查,这会抛出 TypeError: Tx = class Tx { constructor(date) {
我正在使用 args4j 来解析提供给我的程序的参数。 这是我定义 2 个日期类型参数的代码。该处理程序仅解析给定的日期,如果日期格式错误,则抛出 CommandLineException。 @Opt
回归。升级插件后,我的应用程序不再启动。 这是我的 flutter 规范: Flutter 已在稳定 channel 上保持最新状态 Flutter 3.0.2 • channel 稳定 • http
我开发 WPF Prism 6 MVVM 多模块应用程序。直到今天一切正常。但是今天早上我决定清理并重建我的应用程序。在清理和重建后,我的应用程序运行时出现以下错误: PresentationFram
我正在我的 Java EE Maven 项目中使用这个库:https://github.com/bertrandmartel/speed-test-lib 我收到以下异常 java.lang.Clas
我使用假客户端微服务并收到以下错误 - $ mvn spring-boot:run [INFO] Scanning for projects... [INFO] [INFO] ------------
我已经创建了一个调用我的不同模式的服务。所以我有一个模态调用“Confirm Modal”,它可以接受 3 个参数:一个确认函数、一个拒绝函数和一个主体。这是以下模式: export class Co
我正在尝试访问静态列表的值。但是,当我尝试这样做时,会抛出此异常。 System.TypeInitializationException: The type initializer for 'Tips
我将 Spring MVC 与 Spring Boot 和 Thymeleaf 结合使用。我有返回 Thymeleaf 模板名称的普通 Controller 和用 @RepsonseBody 注释的
Objective: {objective 0x7fb7a49de030: + *0x7fb7a4d254b0.negError{id: 1392} + *UIButton:0x7fb7a4b877
我有一个用户报告了这个异常。我在这里和其他地方的研究表明这是一个静态构造函数错误。有关的类包含许多已初始化的静态字段。我认为它是其中之一,但我不确定如何找到它。该建议似乎是在静态构造函数中包含一个 t
我在调用 WCF 服务时收到如下 FaultException: 2012-04-02 16:26:00.3593|Error|System.ServiceModel.FaultException`1
我执行了一个 spark 程序,在该程序中,我使用客户框架将 Drools 规则应用于事实对象。我在 Flatmap 函数中调用了这个自定义框架,并且规则已成功执行,但在收集结果后我看到了以下异常。
我在执行项目时遇到上述错误。当我以正常方式执行它时,它运行良好,没有抛出任何错误。但是当我尝试通过 oozie 将其作为 java 操作调用来运行相同的程序时,它会抛出以下异常 Failing Ooz
我正在使用 JAX-RS jersey ExceptionMapper,我想知道是否有办法在方法 toResponse() 内部知道哪个方法(来自 API)抛出了异常。 示例(伪代码) @javax.
我是 Spring 新手,我正在尝试执行此应用程序,但遇到了这样的异常 SEVERE: Servlet [spring] in web application [/loginDB] threw loa
我是 android 和 xamarin 的新手。最近我根据 xamrarin 示例 TaskyPortable 创建了一个 android 应用程序。问题是每当执行以下代码时都会抛出错误。
我遇到了这个错误,我不知道出了什么问题我只是想检查用户名和密码,然后进入一个显示是否登录的页面 package cse; import java.io.IOException; import java
在 eclipse Juno 上的 Tomcat 6.0.26 中部署我的应用程序时出现以下错误。我将 struts 用于 Web 内容,将 spring 用于 ORM。 我已尝试清理和构建工作区。
我是一名优秀的程序员,十分优秀!