Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
404 Java web服务未找到资源错误_Java_Web Services_Tomcat_Jax Rs - Fatal编程技术网

404 Java web服务未找到资源错误

404 Java web服务未找到资源错误,java,web-services,tomcat,jax-rs,Java,Web Services,Tomcat,Jax Rs,我正在尝试使用一个简单的java Web服务 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://jav

我正在尝试使用一个简单的java Web服务

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">
  <display-name>dcohandleservice</display-name> 

  <servlet>
    <display-name>JAX-RS REST Servlet</display-name>
    <servlet-name>JAX-RS REST Servlet</servlet-name>
    <servlet-class>
        com.sun.jersey.spi.container.servlet.ServletContainer
    </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>JAX-RS REST Servlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
@Produces("application/xml")
@Path("/handles")
@Singleton
public class HandleService {

    File privateKeyFile;

    public HandleService(){
        privateKeyFile = new File("/Users/harsha/Desktop/admpriv.bin");
        //privateKeyFile = new File("/Users/cheny18/Documents/workspace/dcoHandleApplet/admpriv.bin");
    }

    @Produces("text/plain")

    @GET
    @Path("/test")
    public String returnTestString()
    {
        return "<p>this is for testing purpose only</p>";

    }
服务代码的a部分如下所示:

<?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">
  <display-name>dcohandleservice</display-name> 

  <servlet>
    <display-name>JAX-RS REST Servlet</display-name>
    <servlet-name>JAX-RS REST Servlet</servlet-name>
    <servlet-class>
        com.sun.jersey.spi.container.servlet.ServletContainer
    </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>JAX-RS REST Servlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
@Produces("application/xml")
@Path("/handles")
@Singleton
public class HandleService {

    File privateKeyFile;

    public HandleService(){
        privateKeyFile = new File("/Users/harsha/Desktop/admpriv.bin");
        //privateKeyFile = new File("/Users/cheny18/Documents/workspace/dcoHandleApplet/admpriv.bin");
    }

    @Produces("text/plain")

    @GET
    @Path("/test")
    public String returnTestString()
    {
        return "<p>this is for testing purpose only</p>";

    }
在本地计算机上运行web服务时,index.html将正确加载。 但是当我调用localhost:8080/project\u name/services/handles/test时 我得到一个404资源未找到错误


我哪里出错了?

项目名称是实际的上下文路径吗?项目名称是我在eclipse上看到的名称。我认为这没有任何问题。