Atenica Atenica - 8 days ago 9
Java Question

Why jboss service failed to start and why I have 404 error with my rest?

I am new at restful web services. I wanted to write some code where I want when i write this url

http://localhost:8080/EmployeeService-0.0.1-SNAPSHOT/rest/emp/get/101
to get my Employee that i inserted manually.
This is my Employee class:
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(){}
}


This is my rest service:

@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("vujicic.mirela95@gmail.com");
return employee;
}


this is my web.xml:

<?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>


This is my 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>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>


This is my error in console:

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


EDIT: I have solved problem with jboss. Now my only problem is that I receive 404 when I write url that I wrote above. When I start my index.jsp it works but when i run my rest it giving me 404.

And when i write
http://localhost:8080/EmployeeService-0.0.1-SNAPSHOT/rest/emp/get/101
i get 404-not found. Could someone plese help me with these mistakes?

Answer

Have you configure your rest endpoint? Or where does /rest/ comes from?

Example:

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