2014-12-02 147 views
0

當喚醒httpClient.execute調用其餘Web服務時,我從主題中收到錯誤。我讀了兩個有趣的線索,它們與我的情況有些相似。在這兩個線程中,我相信通過增加websphere中的緩衝區8 Liberty配置文件可能會幫助我更好地描述問題,但我不知道在WAS 8.5 Liberty配置文件(不存在管理控制檯)中增加它的位置。我不知道它是否相關,但我放置了(1)用於指導我的線程,這是我在(2)applicationContext.xml中唯一重要的指令,(3)mvc-dispatcher-servlet.xml,( 4)用於其他Web服務的客戶端和(5)POM.xml。可以猜想這些庫有一些問題,因爲這些項目在我將其轉換爲Maven Project之前完全正常工作。有人可以告訴我,如果我錯過了POM中的一些操作?無法設置標題。響應已經提交 - httpClient.execute錯誤

1) WebSphere response buffering Cannot set header in JSP. Response already committed

2)
的applicationContext.xml ... 3)
MVC-調度-servlet.xml中 /WEB-INF/pages/ .JSP ... 4)

@Component 
public class Lo_DisplayHandler extends Lo_Handler { 


    HttpClient httpClient = HttpClientBuilder.create().build(); 
    HttpPost postRequest = new HttpPost("http://localhost:8080/MHE2/log/display/last"); //lastPageUrl); 
    Map<String, String> map = new HashMap<String, String>(); //to map key & value 
… //setting the parameters 
ObjectMapper mapper = new ObjectMapper(); 
String strJson = mapper.writeValueAsString(map);  
StringEntity input = new StringEntity(strJson); 
input.setContentType("application/json"); 
postRequest.setEntity(input); 
HttpResponse response = httpClient.execute(postRequest); //here I got the error [WARNING ] SRVE8094W: WARNING: Cannot set header. Response already committed. 

5)POM

<modelVersion>4.0.0</modelVersion> 
    <groupId>MHE_original</groupId> 
    <artifactId>MHE_original</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 
       <spring.version>4.1.2.RELEASE</spring.version> 
       <java-version>1.6</java-version> 
       <org.aspectj-version>1.7.4</org.aspectj-version> 
       <org.slf4j-version>1.7.5</org.slf4j-version> 
       <jackson.databind-version>2.2.3</jackson.databind-version> 
     </properties> 
     <dependencies> 
       <dependency> 
        <groupId>org.apache.httpcomponents</groupId> 
        <artifactId>httpclient</artifactId> 
        <version>4.1.1</version> 
       </dependency> 
       <dependency> 
        <groupId>javax.servlet</groupId> 
        <artifactId>servlet-api</artifactId> 
        <version>2.5</version> 
       </dependency> 
       <dependency> 
        <groupId>org.codehaus.jackson</groupId> 
        <artifactId>jackson-mapper-asl</artifactId> 
        <version>1.9.12</version> 
       </dependency> 
       <dependency> 
        <groupId>org.springframework</groupId> 
        <artifactId>spring-core</artifactId> 
        <version>${spring.version}</version> 
       </dependency> 
       <dependency> 
        <groupId>org.springframework</groupId> 
        <artifactId>spring-web</artifactId> 
        <version>${spring.version}</version> 
       </dependency> 
       <dependency> 
        <groupId>org.springframework</groupId> 
        <artifactId>spring-webmvc</artifactId> 
        <version>${spring.version}</version> 
       </dependency> 
       <dependency> 
        <groupId>org.springframework</groupId> 
        <artifactId>spring-context</artifactId> 
        <version>${spring.version}</version> 
       </dependency> 
     </dependencies> 
    <build> 
    <sourceDirectory>src</sourceDirectory> 
    <resources> 
     <resource> 
     <directory>src</directory> 
     <excludes> 
      <exclude>**/*.java</exclude> 
     </excludes> 
     </resource> 
    </resources> 
    <plugins> 
     <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.1</version> 
     <configuration> 
      <source>1.6</source> 
      <target>1.6</target> 
     </configuration> 
     </plugin> 
     <plugin> 
     <artifactId>maven-war-plugin</artifactId> 
     <version>2.4</version> 
     <configuration> 
      <warSourceDirectory>WebContent</warSourceDirectory> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 

回答

0

看着你的pom.xml,我看到的一個問題。由於servlet-api與Liberty /任何其他應用程序服務器捆綁在一起,因此您希望將該範圍聲明爲提供,以便它不會與應用程序一起打包,從而導致瓶子發生衝突。類似下面:

`  <rdependency> 
       <groupId>javax.servlet</groupId> 
       <artifactId>servlet-api</artifactId> 
       <version>3.0</version> 
       <scope>provided</scope> 
      </dependency> 
      ` 

至於響應已經提交的錯誤,也不能肯定沒有太多的信息,但可能的原因的根本原因可能是衝突的罐子導致錯誤,如果一個錯誤頁定義重定向在發出實際請求之前發生並已做出響應。

相關問題