简体   繁体   English

REST Web服务404错误-JBoss Eclipse

[英]Rest Web service 404 error - JBoss Eclipse

Hello people I have a problem I can not deploy a restful service on a JBOSS 7.0.1 server, it appears as deployed but the problem is that when I try it by post in a service I get 404 error .... I don't know what to do in this case, with other web projects on the same server I had no problem. 大家好,我有一个问题,我无法在JBOSS 7.0.1服务器上部署静态服务,它似乎已部署,但是问题是,当我在服务中通过邮寄尝试它时,我收到404错误...。不知道在这种情况下该怎么办,对于同一台服务器上的其他Web项目,我没有问题。

It's a project imported from a SVN repository. 这是一个从SVN信息库导入的项目。

The link where i do the post is http://localhost:8080/Project-WAR/ServiceExample/test 我做文章的链接是http:// localhost:8080 / Project-WAR / ServiceExample / test

I have tree projects: 我有树项目:

  • Project-EAR EAR项目
  • Project-EJB 项目EJB
  • Project-WAR 战争计划

server log 服务器日志

14:45:42,850 INFORMACIÓN [org.jboss.modules] JBoss Modules version 1.1.5.GA
14:45:43,131 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
14:45:43,293 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
14:45:44,258 INFO  [org.xnio] XNIO Version 3.0.3.GA
14:45:44,258 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
14:45:44,267 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
14:45:44,282 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.2.GA
14:45:44,298 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
14:45:44,313 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
14:45:44,345 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
14:45:44,376 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
14:45:44,376 INFO  [org.jboss.as.security] (MSC service thread 1-3) JBAS013100: Current PicketBox version=4.0.6.final
14:45:44,392 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
14:45:44,413 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
14:45:44,425 INFO  [org.jboss.as.connector] (MSC service thread 1-4) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
14:45:44,431 INFO  [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
14:45:44,439 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-4) JBAS015400: Bound mail session [java:jboss/mail/Default]
14:45:44,558 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
14:45:44,766 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-4) JBoss Web Services - Stack CXF Server 4.0.1.GA
14:45:44,839 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class com.microsoft.sqlserver.jdbc.SQLServerDriver (version 4.0)
14:45:44,864 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
14:45:45,232 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) Arrancando Coyote HTTP/1.1 en puerto http--0.0.0.0-8080
14:45:45,232 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-2) Arrancando Coyote HTTP/1.1 en puerto http--0.0.0.0-8443
14:45:45,393 INFO  [org.jboss.as.remoting] (MSC service thread 1-6) JBAS017100: Listening on /0.0.0.0:4447
14:45:45,395 INFO  [org.jboss.as.remoting] (MSC service thread 1-5) JBAS017100: Listening on localhost/127.0.0.1:9999
14:45:45,397 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory C:\jboss-as-7.1.0.Final\standalone\deployments
14:45:45,401 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015014: Re-attempting failed deployment Project-EAR.ear
14:45:45,423 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found Project-EAR.ear in deployment directory. To trigger deployment create a file called Project-EAR.ear.dodeploy
14:45:45,626 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "Project-EAR.ear"
14:46:03,066 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-3) Class Path entry jaxb-api.jar in "/C:/jboss-as-7.1.0.Final/standalone/deployments/Project-EAR.ear/jaxb-impl-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
14:46:03,068 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-3) Class Path entry activation.jar in "/C:/jboss-as-7.1.0.Final/standalone/deployments/Project-EAR.ear/jaxb-impl-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
14:46:03,071 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-3) Class Path entry jsr173_1.0_api.jar in "/C:/jboss-as-7.1.0.Final/standalone/deployments/Project-EAR.ear/jaxb-impl-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
14:46:03,074 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-3) Class Path entry jaxb1-impl.jar in "/C:/jboss-as-7.1.0.Final/standalone/deployments/Project-EAR.ear/jaxb-impl-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
14:46:03,077 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-3) Class Path entry jaxb-api.jar in "/C:/jboss-as-7.1.0.Final/standalone/deployments/Project-EAR.ear/jaxb-xjc-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
14:46:03,079 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-3) Class Path entry jaxb-impl.jar in "/C:/jboss-as-7.1.0.Final/standalone/deployments/Project-EAR.ear/jaxb-xjc-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
14:46:03,082 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-3) Class Path entry jsr173_1.0_api.jar in "/C:/jboss-as-7.1.0.Final/standalone/deployments/Project-EAR.ear/jaxb-xjc-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
14:46:03,085 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-3) Class Path entry activation.jar in "/C:/jboss-as-7.1.0.Final/standalone/deployments/Project-EAR.ear/jaxb-xjc-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
14:46:03,089 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-3) Class Path entry activation.jar in "/C:/jboss-as-7.1.0.Final/standalone/deployments/Project-EAR.ear/mail-1.4.jar"  does not point to a valid jar for a Class-Path reference.
14:46:03,097 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "Project-WAR.war"
14:46:03,381 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016002: Processing weld deployment Project-EAR.ear
14:46:03,434 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016002: Processing weld deployment Project-WAR.war
14:46:03,450 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016005: Starting Services for CDI deployment: Project-EAR.ear
14:46:03,483 INFO  [org.jboss.weld.Version] (MSC service thread 1-4) WELD-000900 1.1.5 (AS71)
14:46:03,516 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016008: Starting weld service for deployment Project-EAR.ear
14:46:03,990 INFO  [org.jboss.web] (MSC service thread 1-1) JBAS018210: Registering web context: /Project-WAR
14:46:03,992 INFO  [org.jboss.as] (MSC service thread 1-4) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 21819ms - Started 238 of 327 services (76 services are passive or on-demand)
14:46:04,035 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "Project-EAR.ear"

web.xml web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <display-name>Restful Web Application</display-name>

</web-app>

AplicationConfig.java AplicationConfig.java

package com.services.rest;

import java.util.Set;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("")
public class ApplicationConfig extends Application {

    @Override
    public Set<Class<?>> getClasses() {

        Set<Class<?>> resources = new java.util.HashSet<Class<?>>();
        addRestResourceClasses(resources);
        return resources;
    }

    private void addRestResourceClasses(Set<Class<?>> resources) {
        resources.add(ServiceExample.class);

    }

}

You have to add the followings in the web.xml. 您必须在web.xml中添加以下内容。 It looks like web.xml is is bit empty. 看起来web.xml有点空。 It should look like this. 它应该看起来像这样。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <display-name>Restful Web Application</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>com.services.rest</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>  

You should also have a Resource class which should have at least one end point like this. 您还应该具有一个Resource类,该类至少应具有一个这样的端点。 I provide below an example. 我在下面提供一个例子。

@GET  
@Produces(MediaType.TEXT_PLAIN)  
public String sayHello() {  
   return "Hello World";  
}  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM