编译错误:找不到符号Suspend和AsynchronousResponse

时间:2014-12-07 10:59:33

标签: maven jax-rs resteasy camunda

我正在尝试在Camunda BPM示例项目(embedded-spring-rest)中使用RESTEasy的异步HTTP请求处理功能。要测试现有的pom file是否合适,我将SuspendAsynchronousResponse的导入语句放在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 file看起来没问题。它包含必要的依赖:

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

web.xml file看起来还不错。它包含RESTEasy user guide中建议的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>

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

1 个答案:

答案 0 :(得分:1)

很难说没有看到代码,但Maven错误是一个非常好的信号。我无法弄清楚为什么有人会使用AsynchronousResponseSuspend。现在看到你的link in the comment非常有意义。这是链接

的摘录
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) 

令人遗憾的是,作者甚至在说明中在AsyncResponseAsynchronousResponse之间切换。

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

相关问题