cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <o...@wlkp.org>
Subject processToStream and ConcurrentModificationException
Date Sun, 25 Apr 2004 21:18:57 GMT
Could anybody explain why I get ConcurrentModificationException with this
code:
function test() { 
	var str = "<root><guid>ZXCVXZ-ZXCZXC-#@$-ZXCVZX</guid><contractor>1</contractor><positions><position>abc</position><position>abcd</position><position>abce</position></positions></root>";
	var buffer = new Packages.com.mobilebox.test.OrderSaxBuffer();
	stringToSAX( str, buffer, "true" );
	
	var resolver = null;
	var source = null;
	var pipelineUtil = null;
	try {
		resolver = cocoon.getComponent( SourceResolver.ROLE );
		source = resolver.resolveURI( "context://test.xml" ); 
		
		//var s = new java.io.FileOutputStream( "abc.xml" );
		
		pipelineUtil = cocoon.createObject( Packages.org.apache.cocoon.components.flow.util.PipelineUtil
);
  		pipelineUtil.processToStream( "view/test.jx", { buffer: buffer }, source.outputStream
);
  		source.outputStream.close();
  		
		//s.close();
	} finally {
		if ( source != null ) {
			resolver.release( source );
		}
		if ( resolver != null ) 
			cocoon.releaseComponent( resolver );
			
		if ( pipelineUtil != null )
			cocoon.disposeObject( pipelineUtil );
	}

	cocoon.sendPage( "view/test.jx", { buffer: buffer } );
}

The code that does not use source but a plain FileOutputStream does not throw.

Here is the detailed exception:
org.apache.avalon.framework.CascadingRuntimeException:
"file:/C:/Dev/nTer/build/webapp/test/flow/main.js", line 64: uncaught
JavaScript exception: at test
(file:/C:/Dev/nTer/build/webapp/test/flow/main.js, Line 64):
java.util.ConcurrentModificationException: File
C:\Dev\nTer\build\webapp\test.xml is already being written by another thread

Original Exception: java.util.ConcurrentModificationException: File C:\Dev\nTer\build\webapp\test.xml
is already being written by another thread
	at org.apache.excalibur.source.impl.FileSource.getOutputStream(FileSource.java:324)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.mozilla.javascript.JavaMembers.get(JavaMembers.java:95)
	at org.mozilla.javascript.NativeJavaObject.get(NativeJavaObject.java:100)
	at org.mozilla.javascript.ScriptRuntime.getProp(ScriptRuntime.java:723)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:694)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:190)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:138)
	at org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(InterpretedFunctionImpl.java:121)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.callFunction(FOM_JavaScriptInterpreter.java:686)
	at org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:130)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49)
	at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:101)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:336)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:277)
	at org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:103)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49)
	at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:101)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:336)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:277)
	at org.apache.cocoon.Cocoon.process(Cocoon.java:619)
	at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1074)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
	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:496)


stacktrace[hide] 

org.apache.avalon.framework.CascadingRuntimeException: "file:/C:/Dev/nTer/build/webapp/test/flow/main.js",
line 64: uncaught JavaScript exception: 
at test (file:/C:/Dev/nTer/build/webapp/test/flow/main.js, Line 64):
java.util.ConcurrentModificationException: File C:\Dev\nTer\build\webapp\test.xml is already
being written by another thread
	at org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.callFunction(FOM_JavaScriptInterpreter.java:695)
	at org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:130)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49)
	at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:101)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:336)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:277)
	at org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:103)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49)
	at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:101)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:336)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:277)
	at org.apache.cocoon.Cocoon.process(Cocoon.java:619)
	at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1074)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
	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:496)
Caused by: java.util.ConcurrentModificationException: File C:\Dev\nTer\build\webapp\test.xml
is already being written by another thread
	at org.apache.excalibur.source.impl.FileSource.getOutputStream(FileSource.java:324)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.mozilla.javascript.JavaMembers.get(JavaMembers.java:95)
	at org.mozilla.javascript.NativeJavaObject.get(NativeJavaObject.java:100)
	at org.mozilla.javascript.ScriptRuntime.getProp(ScriptRuntime.java:723)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:694)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:190)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:138)
	at org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(InterpretedFunctionImpl.java:121)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.callFunction(FOM_JavaScriptInterpreter.java:686)
	... 34 more
 

--  
            __
         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/       ouzo@wlkp.org           _\\()//_
         .'/()\'.     Phone: +48(501)720812     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |


Mime
View raw message