2
votes

DISCLAIMER: I have searched whole StackOverflow network, saw a lot of questions with different solutions, but none help as most of them had typos, or wrong .war file name etc. Please, don't mark the question as duplicate.

For the latest project I am working on, I need to use Jersey REST services, but I am totally stuck in 404 error.

Here is the web.xml file:

<?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>

Then, here is the implementation of the REST method I need to invoke:

@Path("/convert")
public class ConvertControllerREST {
    @GET
    @Path("/getcommands")
    @Produces("application/json")
    public List<JSONObject> getCommands() {
        // other logic here
    }

I am calling this REST method on the following URL: http://10.0.2.15:8080/VideoConverter/rest/convert/getcommands

Tomcat 7 logs show no error at all, only 404 - not found when requesting the URL. Downloaded the latest Jersey version available from here: https://jersey.java.net/download.html (RI bundle), and inserted all the .jar files I have found in the bundle above into WEB-INF/lib folder. Also, the .war file I am creating has the same name as stated in the web.xml file: VideoConverter.war.

Any ideas what can be the problem here?

Update 1:

All the jar I am using in the project:

enter image description here

Here are the logs:

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

Update 2:

It seems I have missed some important logs that throw an error:

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'

Update 3:

After changing <servlet-class>:

<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>

to:

<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>

The logs:

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>.

Update 4 (after locating the problem in the media type=application/json):

Got new errors:

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)

Final update: @Meiko answer solves half of the problem. Because new errors appeared, I decided to take his advise and convert the project into Maven archtype to easily solve these problems.

1

1 Answers

1
votes

Edit the init-param for package scanning in your web.xml:

<init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>videoconverter.rest</param-value>
</init-param>

Or (XOR !) update jersey to 2.x and change the servlet-class:

<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>

com.sun.jersey is the package name for jersey 1.x.

org.glassfish.jersey is the base package of jersey 2.x.

Update

The problem:

SEVERE: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.List

You have to add a library which is able to serialize/deserialize JSON (handling the specified media type). See: https://jersey.java.net/documentation/latest/media.html#json

How you can do this is described here too: SEVERE: MessageBodyWriter not found for media type=application/json, type=class com.jersey.jaxb.Todo, genericType=class com.jersey.jaxb.Todo

Just download the bundle here: http://central.maven.org/maven2/org/glassfish/jersey/media/jersey-media-json-jackson/2.22.2/jersey-media-json-jackson-2.22.2.jar

and: http://central.maven.org/maven2/com/fasterxml/jackson/jaxrs/jackson-jaxrs-json-provider/2.7.3/jackson-jaxrs-json-provider-2.7.3.jar

Put the jars in your classpath...

And edit the tag servlet-class to <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>, like already shown. This should be enough.

Advice: I really recommend you to use maven. With a maven archetype you can setup your project very easily:

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

To start this application:

mvn clean package tomcat7:run-war