0

I am getting the error from subject when evoking httpClient.execute to call rest web service. I read two interesting thread that have some thing similiar to my case. From the both thread I believe by increasing buffer in websphere 8 Liberty profile might help me to see a better description of the problem but I don't know where to increase it in WAS 8.5 liberty profile (there isn't admin console). I don't know if it is relevant but I placed the (1) threads I used to guide me, the only important instruction I have in a (2) applicationContext.xml, (3) mvc-dispatcher-servlet.xml, (4) the client for rest web service and (5) POM.xml. Iguess that there is some thing wrong with the libraries because such Project was working perfectly before I converted it to Maven Project. Can someone tell me if I am missing some instraction in POM?

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

2)
applicationContext.xml ... 3)
mvc-dispatcher-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>
Community
  • 1
  • 1
de ca
  • 21
  • 1
  • 6

1 Answers1

0

Looking at your pom.xml, i see one issue. since servlet-api is bundled with liberty/any other application server, you would want to declare the scope as provided so that it will not be packaged with your application also resulting in conflicting jars. Something similar to below:

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

As for the response already committed error, cannot be sure about the rootcause without much info but possible cause could be that the conflicting jars resulted in error and if a error-page was defined redirect happened and response already committed before the actual request can be served.

ezhilxor
  • 149
  • 3