在尝试使用Jersey访问资源时,我一直收到HTTP Status 500错误。我已经尝试了很多东西,到了谷歌搜索的第二页,哈哈,什么都没有。
这是我的代码:
资源类:
@Path("/course")
public class CourseResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getCourse(){
return "this is a dummy course!";
}
}
网状物xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml file is not required when using Servlet 3.0 container,
see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html -->
<web-app version="2.5" 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_2_5.xsd">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.paul.licenta.teachApp</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
</web-app>
波姆。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>org.paul.licenta</groupId>
<artifactId>teachApp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>teachApp</name>
<build>
<finalName>teachApp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<!-- uncomment this to get JSON support
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
-->
</dependencies>
<properties>
<jersey.version>2.26-b06</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
下面是我得到的错误:
type Exception report
message Servlet.init() for servlet Jersey Web Application threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet Jersey Web Application threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.IllegalStateException: InjectionManagerFactory not found.
org.glassfish.jersey.internal.inject.Injections.lambda$lookupInjectionManagerFactory$0(Injections.java:98)
java.util.Optional.orElseThrow(Unknown Source)
org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:98)
org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:93)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:282)
org.glassfish.jersey.servlet.WebComponent.<init>(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:506)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.78 logs.
这是项目浏览器
有什么办法可以让这一切顺利进行吗?提前谢谢!
<jersey.version>2.26-b06</jersey.version>
尝试降级到3月2.26-b03部署的版本。
有同样的错误,所以我决定玩项目方面。发现使用“Java”设置“9”效果很好。
我正在学习Spring MVC,当我试图运行html文件时,它会给出错误HTTP Status 500-引发异常 这是我的web.xml 这是我的Spring调度员Servlet 这是我的jsp页面 这是我的HelloController课程 这是我得到的一个例外 我正在使用Eclipse 4.5.1、Tomcat 8.0.30和Spring 4.2.3。
我在这里的编码
我正在尝试使用简单的Spring MVC项目,但我对Tom Cat有例外 类型异常报告 servlet MVC的消息servlet.init()-Dispatcher引发异常 说明服务器遇到内部错误,导致它无法完成此请求。 我的控制器: My Home.jsp
我完成了这个教程(spring4和hibernate4),我还得到了这个消息: 谁能解释一下是什么问题吗?
我是编程初学者。我试图在windows版本中运行CTAKEAPI,但在试图通过Postman获得响应时出现以下错误。有人能告诉我正确的步骤吗?提前谢谢。
在stackoverflow中有很多这样的错误,但我无法解决我的问题。下面是我的简单配置: 来自TOMCAT服务器的context.xml,我在该服务器上配置了用于访问oracle 11g服务器的数据源 web.xml servlet-context.xml以显示我的bean配置 我不知道它是否有用,但你的动作低于我的控制 例外信息 异常javax.servlet.ServletException