java - RESTEasy 不会引导/初始化

标签 java rest wildfly resteasy

我正在尝试使用 WildFly 的 JAX-RS - RESTEasy 实现来创建一些基于 Java 的 Restful Web 服务,但在部署后启动它时遇到了一些麻烦。

请注意,我正在将 RESTEasy 注释添加到已部署为 .ear 文件的已工作项目中的一组类,这应该没问题吧?需要明确的是,包结构如下所示:

com.something.app
com.something.app.resteasyannotatedclasses

现在我不使用 web.xml 或任何 xml conf 来解决这个问题,只使用记录的注释 here

我只有两个类,RESTEasy Activator:

@ApplicationPath("/coordinates")
public class RestEasyActivator extends Application {
    RestEasyActivator () {
        Logger.getAnonymousLogger().warning("RestEasyActivator Initialised Rest Easy.");
    }
}

实际服务:

@Path("get")
public class CoordinatesServiceWrapper {
    private static final Logger LOG = Logger.getLogger(CoordinatesServiceWrapper.class.getName());

    @GET
    @Path("getByName")
    public String findCoordinates(){
        LOG.info("Called coordinates service!");
        return "Hi";
    }
}

当耳朵部署到 WildFly 时,我看到日志:

WARN [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 4) WELD-000167: Class org.jboss.resteasy.core.AsynchronousDispatcher is annotated with @RequestScoped but it does not declare an appropriate constructor therefore is not registered as a bean!

WARN [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 1) WELD-000167: Class org.jboss.resteasy.plugins.providers.DocumentProvider is annotated with @ApplicationScoped but it does not declare an appropriate constructor therefore is not registered as a bean!

INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 391) WFLYUT0021: Registered web context: '/CoordinateSearch' for server 'default-server'

INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0010: Deployed "CoordinateSearch.ear" (runtime-name : "CoordinateSearch.ear")

我猜与 RESTEasy 相关的警告可以忽略,并且信息消息显示 .ear 已成功部署。

为了调用 Web 服务,我尝试了以下 URL:

Server:port/CoordinateSearch/coordinates/get/getByName/ and Server:port/coordinates/get/getByName/

两者都不会生成任何日志条目。

我错过了什么... 我错过了一些 session 吗? - 看起来非常小。基于 RESTEasy 文档 here WildFly 附带导入的 RESTEasy,它将根据任何包含注释的类进行引导......所以我看不到这个问题。

最佳答案

已回答here ,JAX-RS 通常应该打包在 .war 文件中。

关于java - RESTEasy 不会引导/初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57091373/

相关文章:

java - 在 iOS 上从 *-rpc.discovery 文件编译 lib 时发生错误

java - MongoDB 结果集在执行查询后被修改

java - 我的 Java 代码无法编译。错误可能出在哪里?输出是什么?

json - 错误 : Type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>' in type cast

java - Flask REST POST 请求根据 json 长度失败 "Bad Request"

java - 每个堆栈跟踪行上的 Wildfly 日志日期

angularjs - 带有wildfly的js和css文件的浏览器缓存到期

java - 如何改变android复选框按钮的大小?

javascript - 本网站需要在您的浏览器中启用 Javascript

intellij-idea - WildFly 8.1 : Server is not connected. 部署不可用