- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
免责声明: 我搜索了整个 StackOverflow 网络,看到了很多具有不同解决方案的问题,但没有任何帮助,因为其中大多数都有拼写错误或错误.war 文件名等。请不要将问题标记为重复。
对于我正在进行的最新项目,我需要使用 Jersey REST 服务,但是我完全陷入了 404 错误。
这是 web.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>VideoConverter</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>VideoConverter REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>videoconverter.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>VideoConverter REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
然后,这是我需要调用的 REST 方法的实现:
@Path("/convert")
public class ConvertControllerREST {
@GET
@Path("/getcommands")
@Produces("application/json")
public List<JSONObject> getCommands() {
// other logic here
}
我在以下 URL 上调用此 REST 方法:http://10.0.2.15:8080/VideoConverter/rest/convert/getcommands
Tomcat 7 日志完全没有显示错误,只有 404 - 请求 URL 时未找到。从此处下载最新的 Jersey 版本:https://jersey.java.net/download.html(RI 包),并将我在上面的包中找到的所有 .jar 文件插入到 WEB-INF/lib 文件夹中。此外,我正在创建的 .war 文件与 web.xml 文件中所述的名称相同:VideoConverter.war。
任何想法可能是这里的问题?
更新 1:
我在项目中使用的所有jar
:
这是日志:
catalina.out
Apr 12, 2016 2:49:21 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]
Apr 12, 2016 2:49:21 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]
Apr 12, 2016 2:49:21 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]
Apr 12, 2016 2:49:21 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]
Apr 12, 2016 2:49:21 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
Apr 12, 2016 2:49:21 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]
Apr 12, 2016 2:49:23 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Apr 12, 2016 2:49:23 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1917 ms
Apr 12, 2016 2:49:23 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 12, 2016 2:49:23 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.52 (Ubuntu)
Apr 12, 2016 2:49:23 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/manager.xml
Apr 12, 2016 2:49:25 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/examples.xml
Apr 12, 2016 2:49:29 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Apr 12, 2016 2:49:29 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Apr 12, 2016 2:49:29 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/docs.xml
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/host-manager.xml
Apr 12, 2016 2:49:30 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/VideoConverter.war
Apr 12, 2016 2:49:31 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/VideoConverter/WEB-INF/lib/javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Apr 12, 2016 2:49:36 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
Apr 12, 2016 2:49:37 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Apr 12, 2016 2:49:37 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 11743 ms
Apr 12, 2016 3:03:56 PM org.apache.catalina.util.LifecycleBase stop
INFO: The stop() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/VideoConverter]] after stop() had already been called. The second call will be ignored.
Apr 12, 2016 3:03:56 PM org.apache.catalina.startup.HostConfig undeploy
INFO: Undeploying context [/VideoConverter]
Apr 12, 2016 3:10:10 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/VideoConverter.war
Apr 12, 2016 3:10:11 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/VideoConverter/WEB-INF/lib/javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
localhost_access_log.2016-04-12.txt
10.0.2.15 - - [12/Apr/2016:15:03:43 +0200] "GET /favicon.ico HTTP/1.1" 404 991
10.0.2.15 - - [12/Apr/2016:15:03:45 +0200] "GET /manager/html HTTP/1.1" 401 2486
10.0.2.15 - admin [12/Apr/2016:15:03:52 +0200] "GET /manager/html HTTP/1.1" 200 17602
10.0.2.15 - admin [12/Apr/2016:15:03:55 +0200] "POST /manager/html/stop?path=/VideoConverter&org.apache.catalina.filters.CSRF_NONCE=1DA71E984234CCADB786702A69EA8151 HTTP/1.1" 200 17100
10.0.2.15 - admin [12/Apr/2016:15:03:56 +0200] "POST /manager/html/undeploy?path=/VideoConverter&org.apache.catalina.filters.CSRF_NONCE=8B039406F2DB0A12F2712FA64870DEC0 HTTP/1.1" 200 15899
10.0.2.15 - admin [12/Apr/2016:15:03:57 +0200] "GET /manager/html/list?org.apache.catalina.filters.CSRF_NONCE=60166501ABF61EE3570F9E1E2E01FE39 HTTP/1.1" 200 15841
10.0.2.15 - admin [12/Apr/2016:15:09:58 +0200] "GET /manager/html/list?org.apache.catalina.filters.CSRF_NONCE=5296AEE64D04DF76D1A89216AF48B5F0 HTTP/1.1" 200 15841
10.0.2.15 - admin [12/Apr/2016:15:10:21 +0200] "POST /manager/html/upload?org.apache.catalina.filters.CSRF_NONCE=8A82CD1444765A92D6DD5722490C520E HTTP/1.1" 200 17602
10.0.2.15 - admin [12/Apr/2016:15:10:23 +0200] "GET /manager/html/list?org.apache.catalina.filters.CSRF_NONCE=AEF53F6C5831950965CC133FB5E51C5E HTTP/1.1" 200 17602
10.0.2.15 - - [12/Apr/2016:15:11:30 +0200] "GET /VideoConverter/ HTTP/1.1" 200 416
10.0.2.15 - - [12/Apr/2016:15:11:33 +0200] "GET /VideoConverter/SignUpServlet HTTP/1.1" 200 3456
10.0.2.15 - - [12/Apr/2016:15:11:36 +0200] "GET /VideoConverter/Convert HTTP/1.1" 200 963
10.0.2.15 - - [12/Apr/2016:15:11:36 +0200] "GET /VideoConverter/js/jquery-2.2.3.min.js HTTP/1.1" 304 -
10.0.2.15 - - [12/Apr/2016:15:11:36 +0200] "GET /VideoConverter/js/angular.min.js HTTP/1.1" 304 -
10.0.2.15 - - [12/Apr/2016:15:11:36 +0200] "GET /VideoConverter/js/ConvertController/convert.js HTTP/1.1" 304 -
10.0.2.15 - - [12/Apr/2016:15:11:36 +0200] "GET /VideoConverter/js/main.js HTTP/1.1" 304 -
10.0.2.15 - - [12/Apr/2016:15:11:36 +0200] "GET /VideoConverter/rest/convert/getcommands HTTP/1.1" 404 967
更新 2:
看来我错过了一些抛出错误的重要日志:
localhost.2016-04-12.log
Apr 12, 2016 3:03:51 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: init: Associated with Deployer 'Catalina:type=Deployer,host=localhost'
Apr 12, 2016 3:03:51 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: init: Global resources are available
Apr 12, 2016 3:03:51 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Apr 12, 2016 3:03:54 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: stop: Stopping web application '/VideoConverter'
Apr 12, 2016 3:03:55 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Apr 12, 2016 3:03:56 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: undeploy: Undeploying web application at '/VideoConverter'
Apr 12, 2016 3:03:56 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Apr 12, 2016 3:03:57 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Apr 12, 2016 3:09:58 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Apr 12, 2016 3:10:21 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet VideoConverter REST Service as unavailable
Apr 12, 2016 3:10:21 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /VideoConverter threw load() exception
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1143)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:553)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1648)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1445)
at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:284)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:206)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Apr 12, 2016 3:10:21 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Apr 12, 2016 3:10:23 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
更新 3:
更改 <servlet-class>
后:
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
到:
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
日志:
Apr 12, 2016 3:26:49 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/VideoConverter.war
Apr 12, 2016 3:26:50 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/VideoConverter/WEB-INF/lib/javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Apr 12, 2016 3:26:57 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
Apr 12, 2016 3:26:59 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Apr 12, 2016 3:26:59 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 12173 ms
Apr 12, 2016 3:27:06 PM org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List<org.json.JSONObject>.
Apr 12, 2016 3:27:12 PM org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List<org.json.JSONObject>.
更新 4(在 media type=application/json
中找到问题后):
出现新错误:
javax.servlet.ServletException: Servlet.init() for servlet VideoConverter REST Service threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
java.lang.NoClassDefFoundError: com/fasterxml/jackson/jaxrs/json/JacksonJaxbJsonProvider
org.glassfish.jersey.jackson.JacksonFeature.configure(JacksonFeature.java:85)
org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:730)
org.glassfish.jersey.model.internal.CommonConfig.configureMetaProviders(CommonConfig.java:648)
org.glassfish.jersey.server.ResourceConfig.configureMetaProviders(ResourceConfig.java:829)
org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:453)
org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
org.glassfish.jersey.internal.Errors.process(Errors.java:315)
org.glassfish.jersey.internal.Errors.process(Errors.java:297)
org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:347)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
最后更新:@Meiko 回答解决了一半的问题。由于出现了新的错误,我决定听取他的建议,将项目转换为 Maven archtype 以轻松解决这些问题。
最佳答案
编辑init-param
对于 package scanning在你的 web.xml 中:
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>videoconverter.rest</param-value>
</init-param>
或者(异或!)将 Jersey 更新为 2.x 并更改 servlet-class
:
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
com.sun.jersey是 jersey 1.x 的包名.
org.glassfish.jersey是jersey 2.x的基础包.
更新
问题:
SEVERE: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List
您必须添加一个能够序列化/反序列化 JSON(处理指定媒体类型)的库。请参阅:https://jersey.java.net/documentation/latest/media.html#json
只需在此处下载 bundle :http://central.maven.org/maven2/org/glassfish/jersey/media/jersey-media-json-jackson/2.22.2/jersey-media-json-jackson-2.22.2.jar
将 jar 放在你的类路径中......
并编辑标签servlet-class
至 <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
,就像已经展示的那样。这应该足够了。
建议:我真的推荐你使用 maven。使用 Maven 原型(prototype),您可以非常轻松地设置项目:
mvn archetype:generate \
-DarchetypeArtifactId=jersey-quickstart-webapp \
-DarchetypeGroupId=org.glassfish.jersey.archetypes \
-DinteractiveMode=false \
-DgroupId=com.example \
-DartifactId=simple-service-webapp \
-Dpackage=com.example \
-DarchetypeVersion=2.22.2
要启动这个应用程序:
mvn clean package tomcat7:run-war
关于java - Jersey REST 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36558894/
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码: from PIL import Image from pytesseract import image_
我的错误 /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference
我已经训练了一个模型,我正在尝试使用 predict函数但它返回以下错误。 Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]])
根据Microsoft DataConnectors的信息我想通过 this ODBC driver 创建一个从 PowerBi 到 PostgreSQL 的连接器使用直接查询。我重用了 Micros
我已经为 SoundManagement 创建了一个包,其中有一个扩展 MediaPlayer 的类。我希望全局控制这个变量。这是我的代码: package soundmanagement; impo
我在Heroku上部署了一个应用程序。我正在使用免费服务。 我经常收到以下错误消息。 PG::Error: ERROR: out of memory 如果刷新浏览器,就可以了。但是随后,它又随机发生
我正在运行 LAMP 服务器,这个 .htaccess 给我一个 500 错误。其作用是过滤关键字并重定向到相应的域名。 Options +FollowSymLinks RewriteEngine
我有两个驱动器 A 和 B。使用 python 脚本,我在“A”驱动器中创建一些文件,并运行 powerscript,该脚本以 1 秒的间隔将驱动器 A 中的所有文件复制到驱动器 B。 我在 powe
下面的函数一直返回这个错误信息。我认为可能是 double_precision 字段类型导致了这种情况,我尝试使用 CAST,但要么不是这样,要么我没有做对...帮助? 这是错误: ERROR: i
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
我的数据库有这个小问题。 我创建了一个表“articoli”,其中包含商品的品牌、型号和价格。 每篇文章都由一个 id (ID_ARTICOLO)` 定义,它是一个自动递增字段。 好吧,现在当我尝试插
我是新来的。我目前正在 DeVry 在线学习中级 C++ 编程。我们正在使用 C++ Primer Plus 这本书,到目前为止我一直做得很好。我的老师最近向我们扔了一个曲线球。我目前的任务是这样的:
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的网站中有一段代码有问题;此错误仅发生在 Internet Explorer 7 中。 我没有在这里发布我所有的 HTML/CSS 标记,而是发布了网站的一个版本 here . 如您所见,我在列中有
如果尝试在 USB 设备上构建 node.js 应用程序时在我的树莓派上使用 npm 时遇到一些问题。 package.json 看起来像这样: { "name" : "node-todo",
在 Python 中,您有 None单例,在某些情况下表现得很奇怪: >>> a = None >>> type(a) >>> isinstance(a,None) Traceback (most
这是我的 build.gradle (Module:app) 文件: apply plugin: 'com.android.application' android { compileSdkV
我是 android 的新手,我的项目刚才编译和运行正常,但在我尝试实现抽屉导航后,它给了我这个错误 FAILURE: Build failed with an exception. What wen
谁能解释一下?我想我正在做一些非常愚蠢的事情,并且急切地等待着启蒙。 我得到这个输出: phpversion() == 7.2.25-1+0~20191128.32+debian8~1.gbp108
我是一名优秀的程序员,十分优秀!