在JBoss EAP 6.3中禁用默认的休息服务搜索

时间:2015-05-13 07:46:36

标签: jersey resteasy jboss-eap-6

我需要在JBoss EAP 6.3中禁用默认的rest rest搜索。 我需要在JBoss以及weblogic和websphere中部署相同的EAR,因此不能在特定于JBoss的web.xml中进行更改。

Java类:

package com.first;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/hello")
public class Hello {

  @GET
  @Produces(MediaType.TEXT_PLAIN)
  public String sayPlainTextHello() {
    return "Hello sayPlainTextHello";
  }


  @GET
  @Produces(MediaType.TEXT_XML)
  public String sayXMLHello() {
    return "<?xml version=\"1.0\"?>" + "<hello> Hello sayXMLHello" + "</hello>";
  }

  @GET
  @Produces(MediaType.TEXT_HTML)
  public String sayHtmlHello() {
    return "<html> " + "<title>" + "Hello sayHtmlHello" + "</title>"
        + "<body><h1>" + "Hello String" + "</body></h1>" + "</html> ";
  }

} 

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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>com.first</display-name>
 <servlet>
    <servlet-name>Jersey REST Service</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>

    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.first</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Jersey REST Service</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>resteasy.scan.providers</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>resteasy.scan.resources</param-name>
    <param-value>false</param-value>
</context-param>
</web-app> 

的JBoss部署-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
        <exclude-subsystems>
            <!-- Disable the default JAX-RS subsystem -->
            <subsystem name="jaxrs" />
        </exclude-subsystems>

    </deployment>
</jboss-deployment-structure>

这会引发错误:ResourceConfig实例不包含任何根资源类。

如果我从web.xml中删除以下行,它可以正常工作:

<init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>com.first</param-value>
</init-param>

任何人都可以建议我在没有对web.xml进行更改的情况下应该是理想的方法(理想情况下它应该适用于所有服务器)

由于

1 个答案:

答案 0 :(得分:0)

我自己没有对此进行过测试,但您是否尝试过排除resteasy模块,而不是整个jaxrs子系统? jaxrs模块可能需要在类路径上以支持您的球衣实现。

具体做法是:

  • RestEasy的原子的提供商
  • RestEasy的-CDI
  • RestEasy的-hibernatevalidator提供商
  • resteasy-jackson-provider
  • RestEasy的-JAXB提供商
  • RestEasy的-JAXRS
  • resteasy-jettison-provider
  • RestEasy的-JSAPI
  • RestEasy的-多提供商
  • resteasy-spring
  • RestEasy的-YAML提供商