2014-12-07 59 views
1

我想在Camunda BPM示例项目(嵌入式弹簧休息)中使用RESTEasy的异步HTTP请求处理功能。为了测试现有的pom file是否可以,我在RestProcessEngineDeployment.java中输入了对SuspendAsynchronousResponse的声明。但是编译失败了。编译错误:找不到符号挂起和AsynchronousResponse

[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也看起来没问题。它包含filterfilter-mapping,如RESTEasy user guide中所建议的。

<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

也许你想['javax.ws.rs.container.AsyncResponse'] (https://docs.oracle.com/javaee/7/api/javax/ws/rs/container/AsyncResponse.html)和['@ javax.ws.rs.container.Suspended'](https:// docs .oracle.com/JavaEE的/ 7/API /的javax/WS/RS /容器/ Suspended.html)。很难说没有看到一些代码。 – 2014-12-07 11:48:34

+0

@peeskillet,你是​​对的!我提出错误的进口陈述。我应该注意到,在[RESTEasy用户指南](http://docs.jboss.org/resteasy/docs/3.0.9.Final/userguide/html_single/index。)中,导入语句和实际使用的接口/注释是不同的。 HTML#Asynchronous_HTTP_Request_Processing)。 – 2014-12-07 12:03:46

+0

@peeskillet您能否将评论作为答案。我想接受答案。它解决了这个问题。 – 2014-12-07 23:39:52

回答

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之间的片段。

无论如何,误差可以通过使用正确的进口解决: