2016-11-25 9 views
0

私は安らかなウェブサービスで新しいです。私はこのURLを書くときに私が欲しいところにいくつかのコードを書こうと思っていましたhttp://localhost:8080/EmployeeService-0.0.1-SNAPSHOT/rest/emp/get/101私は手動で挿入した私の従業員を取得します。これは私のpom.xmlあるjbossサービスを開始できなかった理由と残りの404エラーがある理由を教えてください。

<?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_2_5.xsd" version="2.5"> 
    <display-name>EmployeeService</display-name> 
    <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 
</web-app> 

:これは私のweb.xmlのある

@Path("/emp") 
public class EmployeeService { 

    @GET 
    @Path("/get/{empID}") 
    @Produces(MediaType.APPLICATION_XML) 
    public Employee getEmployee(@PathParam("empID") String empID){ 
     Employee employee = new Employee(); 
     employee.setEmpID("101"); 
     employee.setname("Mirela"); 
     employee.setEmail("[email protected]"); 
     return employee; 
    } 

:これは私の残りのサービスは K

@XmlAccessorType(XmlAccessType.NONE) 
@XmlRootElement(name = "employee") 
public class Employee { 
    public String empID; 
    public String name; 
    public String email; 
    @XmlElement(required = true) 
    public String getEmpID() { 
     return empID; 
    } 
    public void setEmpID(String empID) { 
     this.empID = empID; 
    } 
    @XmlElement(required = true) 
    public String gettname() { 
     return name; 
    } 
    public void setname(String firstname) { 
     this.name = firstname; 
    } 
    @XmlElement(required = true) 
    public String getEmail() { 
     return email; 
    } 
    public void setEmail(String email) { 
     this.email = email; 
    } 
    public Employee(String empID, String firstname, String email) { 
     super(); 
     this.empID = empID; 
     this.name = firstname; 
     this.email = email; 
    } 
public Employee(){} 
} 

です: これは私のEmployeeクラスです。

<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>com.com.com</groupId> 
    <artifactId>EmployeeService</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 
    <dependencies> 
    <dependency> 
    <groupId>javax.xml.bind</groupId> 
    <artifactId>jaxb-api</artifactId> 
    <version>2.2.12</version> 
</dependency> 
<dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>javax.servlet-api</artifactId> 
      <version>3.1.0</version> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs --> 
     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>resteasy-jaxrs</artifactId> 
      <version>3.0.19.Final</version> 
      <scope>provided</scope> 
     </dependency> 

    </dependencies> 


</project> 

これはコンソールの私のエラーです:

13:03:27,916 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "EmployeeService-0.0.1-SNAPSHOT.war")]) - failure description: { 
    "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined, 
    "WFLYCTL0288: One or more services were unable to start due to one or more indirect dependencies not being available." => { 
     "Services that were unable to start:" => ["jboss.deployment.unit.\"EmployeeService-0.0.1-SNAPSHOT.war\".PARSE"], 
     "Services that may be the cause:" => ["jboss.remoting.remotingConnectorInfoService.http-remoting-connector"] 
    } 
} 
13:03:27,939 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0010: Deployed "EmployeeService-0.0.1-SNAPSHOT.war" (runtime-name : "EmployeeService-0.0.1-SNAPSHOT.war") 
13:03:27,939 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) WFLYCTL0183: Service status report 
WFLYCTL0186: Services which failed to start:  service jboss.undertow.listener.default: org.jboss.msc.service.StartException in service jboss.undertow.listener.default: Address already in use: bind localhost/127.0.0.1:8080 
     service jboss.undertow.listener.https: org.jboss.msc.service.StartException in service jboss.undertow.listener.https: Address already in use: bind localhost/127.0.0.1:8443 

編集:私はjbossの問題を解決しました。今私の唯一の問題は、私が上記で書いたURLを書くときに404を受け取ることです。 index.jspを起動すると動作しますが、残りの部分を実行すると404が表示されます。

そして、http://localhost:8080/EmployeeService-0.0.1-SNAPSHOT/rest/emp/get/101と書くと404が見つかりません。誰かがこれらの間違いを私に助けてくれますか?

+0

'住所:バインドはlocalhost/127.0.0.1:あなたは二回 – Kayaman

+0

チェックプロセス実行中 –

+0

をJBossの開始しているが、Javaがある場合は、私のwildflyとTomcatが – Atenica

答えて

1

残りのエンドポイントを設定しましたか?または/ rest /はどこから来ますか?

例:すでに使用中の

@ApplicationPath("/rest") 
public class JaxRsActivator extends Application { 
} 
+0

ありがとう!これはちょうど私が逃したことです。ちょうど1つの質問...アプリケーションを拡張するこのクラスを設定すると、web.xmlにmappサーブレットを持たないのですか? – Atenica

+0

はい、web.xmlはまったく必要ないかもしれません –

関連する問題