cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fawzib Rojas <f_ro...@spectron-msim.com>
Subject Re: Question about serializers
Date Fri, 16 Dec 2005 12:37:49 GMT
Mark Lundquist wrote:

>
> On Dec 15, 2005, at 7:45 AM, Fawzib Rojas wrote:
>
>> Is there a way to create a thread in flowscript and have the 
>> "cocoon.processPipeline" run in it?
>
>
> Yes, definitely...
>
Well I tried it but it isnt working, If I set use_thread=false it works, 
if I set use_thread=true. I know the pdf_runnable object is working 
because pdf_runnable.process() works, but when I call it from the thread 
it fails. I get some errors in the console and logs, they are after the 
script. Can anyone give a hand with this, I'm very close...

function main() {
    var use_thread=true;
    // get path
    var 
path=cocoon.parameters["report"]+".pdf_pipe?"+getRequestParameters();
    // create runnable
        var pdf_runnable=new java.lang.Runnable(
            { 
            "complete": false,
            "count": 0,
            "url":path,
            "error":"no error",
            "cocoon": cocoon,
            "out_stream":new java.io.ByteArrayOutputStream(),
            "run": function(){
                this.process();
                this.complete=true;
            },
            "process": function(){
                this.cocoon.processPipelineTo(this.url,'',this.out_stream);
            }
        }
          );
    //
    if(use_thread){
        var pdf_thread=new java.lang.Thread(pdf_runnable);
        pdf_thread.start();
        // wait until thread is done
        pdf_runnable.count=0;
            while(pdf_runnable.complete==false) {
                cocoon.sendPageAndWait("progress.jx", { "stream_size" : 
pdf_runnable.out_stream.size(),"count":pdf_runnable.count } );
                pdf_runnable.count++;
            }
    }else{
        pdf_runnable.process();
    }
    //
    cocoon.sendPage(
        "pdf-display/"+path,
        {byteArray : new 
java.io.ByteArrayInputStream(pdf_runnable.out_stream.toByteArray())}
    );
}

Console error:

java.lang.NullPointerException
    at 
org.apache.cocoon.environment.AbstractEnvironment.release(AbstractEnvironment.java:539)
    at 
org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade.release(MutableEnvironmentFacade.java:320)
    at 
org.apache.cocoon.transformation.TraxTransformer.recycle(TraxTransformer.java:514)
    at 
org.apache.avalon.excalibur.pool.ResourceLimitingPool.put(ResourceLimitingPool.java:438)
    at 
org.apache.avalon.excalibur.component.PoolableComponentHandler.doPut(PoolableComponentHandler.java:212)
    at 
org.apache.avalon.excalibur.component.ComponentHandler.put(ComponentHandler.java:425)
    at 
org.apache.avalon.excalibur.component.ExcaliburComponentSelector.release(ExcaliburComponentSelector.java:305)
    at 
org.apache.cocoon.components.ExtendedComponentSelector.release(ExtendedComponentSelector.java:284)
    at 
org.apache.cocoon.components.ExtendedComponentSelector.release(ExtendedComponentSelector.java:281)
    at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.recycle(AbstractProcessingPipeline.java:650)
    at 
org.apache.cocoon.components.pipeline.impl.BaseCachingProcessingPipeline.recycle(BaseCachingProcessingPipeline.java:77)
    at 
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.recycle(AbstractCachingProcessingPipeline.java:948)
    at 
org.apache.avalon.excalibur.pool.ResourceLimitingPool.put(ResourceLimitingPool.java:438)
    at 
org.apache.avalon.excalibur.component.PoolableComponentHandler.doPut(PoolableComponentHandler.java:212)
    at 
org.apache.avalon.excalibur.component.ComponentHandler.put(ComponentHandler.java:425)
    at 
org.apache.avalon.excalibur.component.ExcaliburComponentSelector.release(ExcaliburComponentSelector.java:305)
    at 
org.apache.cocoon.components.ExtendedComponentSelector.release(ExtendedComponentSelector.java:284)
    at 
org.apache.cocoon.components.EnvironmentDescription.release(CocoonComponentManager.java:599)
    at 
org.apache.cocoon.components.CocoonComponentManager.endProcessing(CocoonComponentManager.java:204)
    at org.apache.cocoon.Cocoon.process(Cocoon.java:683)
    at 
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1098)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at 
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:354)
    at 
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
    at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1808)
    at 
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:525)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1758)
    at org.mortbay.http.HttpServer.service(HttpServer.java:879)
    at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
    at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:952)
    at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
    at 
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197)
    at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
    at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:501)
org.mozilla.javascript.WrappedException: WrappedException of
at  (file:/opt/cocoon/build/webapp/msim/flow/print_pdf.js, Line 32):
org.mozilla.javascript.WrappedException: WrappedException of
at  (file:/opt/cocoon/build/webapp/msim/flow/print_pdf.js, Line 36):
org.apache.excalibur.source.SourceException: Exception during processing 
of cocoon://msim/MonitorList-corrections.pdf_pipe?
    at 
org.mozilla.javascript.WrappedException.wrapException(WrappedException.java:111)
    at org.mozilla.javascript.JavaAdapter.callMethod(JavaAdapter.java:390)
    at adapter0.run(<adapter>)
    at java.lang.Thread.run(Thread.java:534)

Error in the logs:

org.apache.cocoon.ProcessingException: Unable to remove component from 
automatic release: no environment available.
    at 
org.apache.cocoon.components.CocoonComponentManager.removeFromAutomaticRelease(CocoonComponentManager.java:448)
    at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.release(AbstractProcessingPipeline.java:173)
    at 
org.apache.cocoon.components.source.impl.SitemapSource.reset(SitemapSource.java:454)
    at 
org.apache.cocoon.components.source.impl.SitemapSource.recycle(SitemapSource.java:477)
    at 
org.apache.cocoon.components.source.impl.SitemapSourceFactory.release(SitemapSourceFactory.java:78)
    at 
org.apache.excalibur.source.impl.SourceResolverImpl.release(SourceResolverImpl.java:269)
    at 
org.apache.cocoon.components.CocoonComponentManager.release(CocoonComponentManager.java:507)
    at 
org.apache.cocoon.components.CocoonComponentManager.release(CocoonComponentManager.java:507)
    at 
org.apache.cocoon.components.CocoonComponentManager.release(CocoonComponentManager.java:507)
    at 
org.apache.cocoon.environment.AbstractEnvironment.release(AbstractEnvironment.java:539)
    at 
org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade.release(MutableEnvironmentFacade.java:320)
    at 
org.apache.cocoon.generation.FileGenerator.recycle(FileGenerator.java:64)
    at 
org.apache.avalon.excalibur.pool.ResourceLimitingPool.put(ResourceLimitingPool.java:438)
    at 
org.apache.avalon.excalibur.component.PoolableComponentHandler.doPut(PoolableComponentHandler.java:212)
    at 
org.apache.avalon.excalibur.component.ComponentHandler.put(ComponentHandler.java:425)
    at 
org.apache.avalon.excalibur.component.ExcaliburComponentSelector.release(ExcaliburComponentSelector.java:305)
    at 
org.apache.cocoon.components.ExtendedComponentSelector.release(ExtendedComponentSelector.java:284)
    at 
org.apache.cocoon.components.ExtendedComponentSelector.release(ExtendedComponentSelector.java:281)
    at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.recycle(AbstractProcessingPipeline.java:638)
    at 
org.apache.cocoon.components.pipeline.impl.BaseCachingProcessingPipeline.recycle(BaseCachingProcessingPipeline.java:77)
    at 
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.recycle(AbstractCachingProcessingPipeline.java:948)
    at 
org.apache.avalon.excalibur.pool.ResourceLimitingPool.put(ResourceLimitingPool.java:438)
    at 
org.apache.avalon.excalibur.component.PoolableComponentHandler.doPut(PoolableComponentHandler.java:212)
    at 
org.apache.avalon.excalibur.component.ComponentHandler.put(ComponentHandler.java:425)
    at 
org.apache.avalon.excalibur.component.ExcaliburComponentSelector.release(ExcaliburComponentSelector.java:305)
    at 
org.apache.cocoon.components.ExtendedComponentSelector.release(ExtendedComponentSelector.java:284)
    at 
org.apache.cocoon.components.EnvironmentDescription.release(CocoonComponentManager.java:599)
    at 
org.apache.cocoon.components.CocoonComponentManager.endProcessing(CocoonComponentManager.java:204)
    at org.apache.cocoon.Cocoon.process(Cocoon.java:683)
    at 
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1098)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at 
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:354)
    at 
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
    at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1808)
    at 
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:525)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1758)
    at org.mortbay.http.HttpServer.service(HttpServer.java:879)
    at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
    at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:952)
    at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
    at 
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197)
    at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
    at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:501)


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message