2014-12-07 94 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之間的片段。

無論如何,誤差可以通過使用正確的進口解決: