users@jersey.java.net

[Jersey] Re: Hello ,somebody could help me why this code alwaysreturning 404?

From: Redmond_at_139. <redmond_at_139.com>
Date: Mon, 5 Oct 2015 17:16:26 +0800 (CST)

Hello sir
  after taking a look at the example,I have modified the web.xml file,here is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>myrest</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>service</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>myrest</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

however,I still get the 404 error
here is the tomcat log message

信息: validateJarFile(D:\javatest\slservice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\slervice\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
十月 05, 2015 5:07:09 下午 org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
十月 05, 2015 5:07:09 下午 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet [myrest] in web application [/slwebservice] threw load() exception
java.lang.ClassNotFoundException: service
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1858)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1709)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:191)
    at org.glassfish.jersey.internal.util.ReflectionHelper$7.run(ReflectionHelper.java:408)
    at org.glassfish.jersey.internal.util.ReflectionHelper$7.run(ReflectionHelper.java:398)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:493)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:327)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:362)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5253)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5543)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    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)

十月 05, 2015 5:07:09 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
十月 05, 2015 5:07:09 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
十月 05, 2015 5:07:09 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 1348 ms

what I should do?how do I handle this exception? thanks
regards
Ken




--------------------------------------------------------------------------------




------------------ 原始邮件 ------------------




 
 发件人: Pavel Bucek <pavel.bucek_at_oracle.com>
 

 
 发送时间: 2015-10-02 23:47:15
 

 
 收件人: users <users_at_jersey.java.net>
 

 
 抄送: (无)
 

 
 主题: [Jersey] Re: Hello ,somebody could help me why this code alwaysreturning 404?
 



 Hi Ken,
 
 we will need to know more info - for example, how do you build this (is it a war?), where do you deploy it, what returns 404?
 
 looking at web.xml - you seem to use doc from Jersey 1.x (com.sun.jersey.* classes), but you have Jersey 2 in WebContent/WEB-INF/lib directory.
 
 Maybe you should start with something which work - feel free to check-out Jersey 2 examples:
 
 https://github.com/jersey/jersey/tree/2.x/examples
 
 try "helloworld-webapp" first.
 
 https://github.com/jersey/jersey/tree/2.x/examples/helloworld-webapp
 
 Hope it helps,
 Pavel
 
 
On 02/10/15 17:36, Redmond_at_139. wrote:
 
 

 hello sir/madam
    this is my program in github,https://github.com/abcdef123ghi/jerseytest ,there are no errors in Eclipse,However it always returing the 404,any help would be appeciated.Although I'm not familar with Java,but with Google & Jersey docs,I have written the code and there are no errors,but it can't be started.I'm very confused.
 regards
 Ken