0

I have a problem testing a simple Restful service on JBoss.

I have built the project and deployed to JBoss fine. This is my Deployer written using Java:

import javax.ws.rs.core.Application;

public class Deployer extends Application {

}

This is my web.xml:

<?xml version="1.0"?>

<web-app>
    <servlet-mapping>
        <servlet-name>com.mxyy.orderservice.deploy.Deployer</servlet-name>
        <url-pattern>/orderservice/*</url-pattern>
    </servlet-mapping>
</web-app>

This is my Restful service interface written in Scala:

@Provider
@Path("/customers")
trait ICustomerService {
  @POST
  @Consumes(Array("application/xml"))
  def createCustomer(is: InputStream): Response

  @GET
  @Path("{id}")
  @Produces(Array("application/xml"))
  def getCustomer(@PathParam("id") id: Int): StreamingOutput

  @PUT
  @Path("{id}")
  @Consumes(Array("application/xml"))
  def updateCustomer(@PathParam("id") id: Int, is: InputStream): Unit
}

This interface is implemented.

After I deployed to JBoss, I tried to access the service by typing:

 http://localhost:8080/orderservice/customers/1

The browser respond with

HTTP Status 404 - /orderservice/customers/1    

type Status report    
message /orderservice/customers/1    
description The requested resource (/orderservice/customers/1) is not available.

Can someone point out what I did wrong?

Many thanks.

Kevin
  • 5,972
  • 17
  • 63
  • 87

1 Answers1

0

i think everything is fine there except a small mistake that's "/". just edit as:

@Provider
@Path("/customers")
trait ICustomerService {
@POST
@Consumes(Array("application/xml"))
def createCustomer(is: InputStream): Response

@GET
@Path("/{id}")
@Produces(Array("application/xml"))
def getCustomer(@PathParam("id") id: Int): StreamingOutput

@PUT
@Path("/{id}")
@Consumes(Array("application/xml"))
def updateCustomer(@PathParam("id") id: Int, is: InputStream): Unit
}

Inform me if it works. :)

amit sharma
  • 210
  • 2
  • 9