Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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
Java 404 Jersery web.xml不工作_Java_Xml_Rest_Maven_Jersey - Fatal编程技术网

Java 404 Jersery web.xml不工作

Java 404 Jersery web.xml不工作,java,xml,rest,maven,jersey,Java,Xml,Rest,Maven,Jersey,我不能用玻璃鱼做运动衫。我不明白什么不起作用。我现在很沮丧: 当我尝试访问以下URL之一时,我得到404: pom.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

我不能用玻璃鱼做运动衫。我不明白什么不起作用。我现在很沮丧:

当我尝试访问以下URL之一时,我得到404:

pom.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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>UPMSocial_130171_130074</groupId>
  <artifactId>UPMSocial_130171_130074</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>2.22.2</version>
        <scope>provided</scope>
    </dependency>
    <!-- if you are using Jersey client specific features without the server side -->
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>2.22.2</version>
        <scope>provided</scope>
    </dependency>
 </dependencies>

  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

只有那些特定的url?其他url是否按预期工作?还有,你有任何类型的错误日志可以提供吗?没有URL工作,日志似乎没有错误。WEB-INF/lib是空的,因为
提供了
这可能是我的问题。因为glassfish已经有了Jersey,它似乎必须按照提供的配置。通常,如果您没有定义上下文根,它会得到您的WAR的名称,它将是
UPMSocial_130171_130074-0.0.1-SNAPSHOT
。如果是这样的话,那么您应该通过以下方式访问RESTAPI:@aribeiro我也尝试过,但没有成功。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
 <display-name>UPMSocial_130171_130074</display-name>
 <servlet>
    <servlet-name>Jersey REST Service</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>upm.social.servicios.Servidor</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
    <servlet-name>Jersey REST Service</servlet-name>
    <url-pattern>/rest/*</url-pattern>
 </servlet-mapping>
</web-app>
@Path("/api")
public class Servidor {

    @GET
    @Produces(MediaType.APPLICATION_XML)
    public Response getUsers(