部署在JBoss上的RESTful服务没有响应
我在 JBoss 上测试简单的 Restful 服务时遇到问题。
我已经构建了该项目并部署到 JBoss 上。这是我用 Java 编写的 Deployer:
import javax.ws.rs.core.Application;
public class Deployer extends Application {
}
这是我的 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>
这是我用 Scala 编写的 Restful 服务接口:
@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
}
这个接口已实现。
部署到 JBoss 后,我尝试通过键入以下内容来访问该服务:
http://localhost:8080/orderservice/customers/1
浏览器响应
HTTP Status 404 - /orderservice/customers/1
type Status report
message /orderservice/customers/1
description The requested resource (/orderservice/customers/1) is not available.
Can 有人指出我做错了什么吗?
非常感谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为一切都很好,除了一个小错误“/”。
只需编辑为:
如果有效请通知我。 :)
i think everything is fine there except a small mistake that's "/".
just edit as:
Inform me if it works. :)