JBoss AS 7 Restful Webservices无法自动部署 [英] JBoss AS 7 Restful Webservices not auto deploying

查看:105
本文介绍了JBoss AS 7 Restful Webservices无法自动部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将内置的Restful WebServices与JBoss AS 7一起使用.我的web.xml是..

I'm trying to use the built in Restful WebServices with JBoss AS 7. My web.xml is..

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

</web-app>

我的应用程序类是...

My application class is...

package com.robert;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;

@ApplicationPath("/services")

public class HelloWorld extends Application {
private Set<Object> singletons = new HashSet<Object>();

public HelloWorld() {
    singletons.add(new Library());
}

@Override
public Set<Class<?>> getClasses() {
    Set<Class<?>> classes = new HashSet<Class<?>>();
    classes.add(Library.class);
    return classes;    //To change body of overridden methods use File | Settings | File Templates.
}

@Override
public Set<Object> getSingletons() {
    return singletons;
}

}

我的班级是

import javax.ws.rs.*;

@Path("/library")
public class Library {

@GET
@Path("/books")
public String getBooks() {
    return "this is all your books";
}

@GET
@Path("/book/{isbn}")
public String getBook(@PathParam("isbn") String id) {
    // search my database and get a string representation and return it
    return "Its a good book; I read it";
}

@PUT
@Path("/book/{isbn}")
public void addBook(@PathParam("isbn") String id, @QueryParam("name") String name) {
    System.out.println("Adding book "+name);
}

@DELETE
@Path("/book/{id}")
public void removeBook(@PathParam("id") String id ){
    System.out.println("Removing book "+id);

}

}

但是,当我启动JBoss AS7时,WebService永远不会启动.我在JBoss管理页面中看不到它,在

However, when I start JBoss AS7 the WebService is never started. I don't see it int he JBoss Management page and I don't see it at

http://foobar:8080/MyWar/services/library/books

推荐答案

好,我发现了问题.按照RestEasy的指示,我已将最新版本的RestEasy安装到JBoss模块中.当我恢复为默认安装时,它可以正常工作.请注意,当JBoss部署程序在类上看到@ApplicationPath注释时,JBoss部署程序会自动部署RestEasy,因此web.xml 绝不能包含任何对Restful servlet的引用. Web.xml应该为空.

Ok, I discovered the problem. Following the directions from RestEasy I had installed the latest version of RestEasy into the JBoss module. When I reverted back to the default installation it work. Note that the web.xml MUST NOT contain any reference to the Restful servlets as the JBoss deployer auto deploys RestEasy when it sees the @ApplicationPath annotation on a class. Web.xml should be empty.

这篇关于JBoss AS 7 Restful Webservices无法自动部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆