I am trying to understand, how the SitePublisher/LiveSite controllers work. I read the document. Started implementing the example given in the document.
I created a java file with following code,
[HTML]
package com.interwoven.livesite.external.runtime.example;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import com.interwoven.livesite.common.web.StopForwardAction;
import com.interwoven.livesite.common.web.ForwardAction;
import com.interwoven.livesite.common.web.URLRedirectForwardAction;
import com.interwoven.livesite.runtime.RequestContext;
public class SampleTask
{
/**
* Override output
*
*
@Param context runtime context
*
@return forward action
*
@throws IOException write exception
*/
public ForwardAction methodOutput(RequestContext context) throws IOException
{
try {
File outfilename = new File("E:\\/apps\\/Interwoven\\/TeamSite\\/local\\/logs\\/controller.txt");
BufferedWriter out = new BufferedWriter(new FileWriter(outfilename));
out.write("Inside MethodOutput" );
ServletOutputStream output = context.getResponse().getOutputStream();
context.getResponse().setContentType("text/html");
context.getResponse().setStatus(HttpServletResponse.SC_OK);
output.print("Output overridden, have a nice day.");
output.flush();
out.close();
} catch (Exception e) {
File outfilename = new File("E:\\/apps\\/Interwoven\\/TeamSite\\/local\\/logs\\/controller_exception.txt");
BufferedWriter out = new BufferedWriter(new FileWriter(outfilename));
out.write(e.getMessage());
}
return new StopForwardAction();
}
}
[/HTML]
Placed this java file at,
[HTML]
E:\apps\Interwoven\TeamSite\local\config\lib\content_center\livesite_customer_src\src\com\interwoven\livesite\external\runtime\example
[/HTML]
Created a page and in page settings for the "Page Pre Controllers" I specified object as,
[HTML]com.interwoven.livesite.external.runtime.example.SampleTask[/HTML]
and method as [HTML]methodOutput[/HTML].
Then saved the page and edited back, I checked the log file, nothing was there and then I added a component to that page, log file name controller.txt got created with text 'Inside MethodOutput'.
The problem I am facing is, the component is not getting loaded completely, instead it's hanging.
When I check content of servletd_out.log, I can see following error in it.
[HTML]
Jan 7, 2010 4:38:56 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:610)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at com.interwoven.livesite.iw.servlet.preview.rendering.PagePaletteRenderingManager.handleError(PagePaletteRenderingManager.java:192)
at com.interwoven.livesite.iw.servlet.preview.rendering.PagePaletteRenderingManager.render(PagePaletteRenderingManager.java:155)
at com.interwoven.livesite.runtime.impl.BaseRequestContext.render(BaseRequestContext.java:237)
at com.interwoven.livesite.iw.servlet.preview.PagePaletteFilter.doFilter(PagePaletteFilter.java:71)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:183)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:138)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
04:40:12,668 WARN [RuntimeControllerExecutor] Controller returned illegal ForwardAction; controller=com.interwoven.livesite.runtime.controller.RuntimeController@18c908b[object=com.interwoven.livesite.external.runtime.example.SampleTask,method=public com.interwoven.livesite.common.web.ForwardAction methodOutput(com.interwoven.livesite.runtime.RequestContext,),scope=,parameters={}]
04:40:12,715 ERROR [PagePaletteRenderingManager] Failed to render the component
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:610)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at com.interwoven.livesite.model.page.PreviewPage.renderHtmlComponent(PreviewPage.java:403)
at com.interwoven.livesite.model.page.PreviewPage.renderPaletteComponentPage(PreviewPage.java:251)
at com.interwoven.livesite.iw.servlet.preview.rendering.PagePaletteRenderingManager.render(PagePaletteRenderingManager.java:150)
at com.interwoven.livesite.runtime.impl.BaseRequestContext.render(BaseRequestContext.java:237)
at com.interwoven.livesite.iw.servlet.preview.PagePaletteFilter.doFilter(PagePaletteFilter.java:71)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:183)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:138)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
[/HTML]
Any help will be appreciated, with the mistake I am doing.
Thanks,