1

我正在尝试在 Camunda BPM 示例项目(embedded-spring-rest)中使用带有 RESTEasy 的异步 HTTP 请求处理功能。为了测试现有的pom 文件是否正常,我将 import 语句 forSuspendAsynchronousResponsein 放在RestProcessEngineDeployment.java. 但是maven编译失败了。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project camunda-quickstart-embedded-spring-rest: Compilation failure: Compilation failure:
[ERROR] /home/vagrant/works/eclipse-workspace/camunda-bpm-examples/deployment/embedded-spring-rest/src/main/java/org/camunda/bpm/example/loanapproval/rest/RestProcessEngineDeployment.java:[7,19] cannot find symbol
[ERROR] symbol:   class Suspend
[ERROR] location: package javax.ws.rs
[ERROR] /home/vagrant/works/eclipse-workspace/camunda-bpm-examples/deployment/embedded-spring-rest/src/main/java/org/camunda/bpm/example/loanapproval/rest/RestProcessEngineDeployment.java:[8,24] cannot find symbol
[ERROR] symbol:   class AsynchronousResponse
[ERROR] location: package javax.ws.rs.core

POM 文件看起来没问题。它包含必要的依赖项:

<dependency>
  <groupId>org.jboss.resteasy</groupId>
  <artifactId>resteasy-jaxrs</artifactId>
  <version>3.0.8.Final</version>
</dependency>

web.xml 文件看起来也不错。它包含RESTEasy 用户指南filterfilter-mapping的建议。

  <filter>
    <filter-name>Resteasy</filter-name>
    <filter-class>
        org.jboss.resteasy.plugins.server.servlet.FilterDispatcher
    </filter-class>
    <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>org.camunda.bpm.example.loanapproval.rest.RestProcessEngineDeployment</param-value>
    </init-param>
  </filter>

  <filter-mapping>
      <filter-name>Resteasy</filter-name>
      <url-pattern>/*</url-pattern>
  </filter-mapping>

我错过了什么吗?关于我如何找出问题的任何线索?

4

1 回答 1

1

没有看到代码很难判断,但 Maven 错误是一个很好的信号。我只是想不通为什么有人会使用AsynchronousResponseand Suspend。现在在评论中看到您的链接非常有意义。这是链接中的一个片段

import javax.ws.rs.Suspend;
import javax.ws.rs.core.AsynchronousResponse;

@Path("/")
public class SimpleResource {
   @GET
   @Path("basic")
   @Produces("text/plain")
   public void getBasic(@Suspended final AsyncResponse response) 

AsyncResponse可悲的是,作者甚至AsynchronousResponse在描述之间切换。

无论如何,可以通过使用正确的导入来解决错误:

于 2014-12-08T00:10:03.740 回答