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 Runnable in flowscript?
Date Fri, 19 Mar 2010 14:40:51 GMT
I'm trying to create a pipeline in the background using a thread. My 
flowscript looks like this:

function create_pdf() {
     var output_file=java.io.File.createTempFile("temp",".pdf");
     var output_stream=new MyOutputStream(output_file);
     //
     var r = new java.lang.Runnable() {
         run: function() {
             
cocoon.processPipelineTo("pdf-create-pipeline'',output_stream);
             output_stream.close();
         }
    };
    new java.lang.Thread(r).start();
    // Display the waiting page until file is closed
    while(!output_stream.isClosed()) {
        cocoon.sendPageAndWait("progress.jx",{ "length" :  
output_stream.length(), "output_path" : output_file.getCanonicalPath(), });
    }
    // send the page
    cocoon.sendPage( "pdf-send-pipeline", {file_name : 
output_file.getCanonicalPath() } );
   }
}

I know the thread is working, but it seems I'm missing something cocoon 
related that I must initialize in the thread. I get the following exception:

Exception in thread "Thread-19" org.mozilla.javascript.WrappedException: 
Wrapped org.apache.avalon.framework.CascadingRuntimeException: Unable to 
get the object model from the context. 
(file:/C:/cocoon/msim_app/msim/flow/print_pdf.js#28)
     at 
org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1693)
     at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:160)
     at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:471)
     at 
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3085)
     at script(file:/C:/cocoon/msim_app/msim/flow/print_pdf.js:28)
     at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2251)
     at 
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:161)
     at 
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:340)
     at 
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2758)
     at 
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:159)
     at org.mozilla.javascript.Context.call(Context.java:499)
     at org.mozilla.javascript.JavaAdapter.callMethod(JavaAdapter.java:492)
     at adapter1.run(<adapter>)
     at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.avalon.framework.CascadingRuntimeException: Unable 
to get the object model from the context.
     at 
org.apache.cocoon.components.ContextHelper.getObjectModel(ContextHelper.java:92)
     at 
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.setupView(FOM_JavaScriptInterpreter.java:877)
     at 
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.process(FOM_JavaScriptInterpreter.java:872)
     at 
org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon.jsFunction_processPipelineTo(FOM_Cocoon.java:286)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:145)
     ... 11 more
Caused by: org.apache.avalon.framework.context.ContextException: Unable 
to locate object-model (No environment available)
     at 
org.apache.cocoon.components.ComponentContext.get(ComponentContext.java:96)
     at 
org.apache.cocoon.components.ContextHelper.getObjectModel(ContextHelper.java:90)
     ... 19 more




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


Mime
View raw message