java.util.concurrent.CancellationException in case of lost connection

973 views
Skip to first unread message

nraynaud

unread,
Sep 23, 2009, 8:08:59 AM9/23/09
to JODConverter
Hi all,
I think there is a synchronisation bug in the PooledOfficeManager.

My main thread starts an officemanager, sends one by one a collection
of tasks to execute and stops the manager. Sometimes (I don't yet know
why), the OpenOffice process calls the event on the xbridge which
cancels the current task, and starts a new one. But this event is
called from another thread and my thread is still trying to send some
new work to the manager. Since there is no lock and the ne openoffice
is not yet ready, the manager try to use the old canceled futureTask
which leads to a CancellationException.

here is the full transcript of the session :

23 sept. 2009 13:37:03
org.artofsolving.jodconverter.office.ProcessPoolOfficeManager <init>
INFO: ProcessManager implementation is MacProcessManager
23 sept. 2009 13:37:03
org.artofsolving.jodconverter.office.OfficeProcess
prepareInstanceProfileDir
ATTENTION: profile dir '/var/folders/yD/yDMRSGr92RWjfE+8ZM3lcU+++TI/-
Tmp-/.jodconverter_socket_host-127.0.0.1_port-2002' already exists;
deleting
23 sept. 2009 13:37:04
org.artofsolving.jodconverter.office.OfficeProcess start
INFO: starting process with acceptString
'socket,host=127.0.0.1,port=2002,tcpNoDelay=1' and profileDir '/var/
folders/yD/yDMRSGr92RWjfE+8ZM3lcU+++TI/-
Tmp-/.jodconverter_socket_host-127.0.0.1_port-2002'
23 sept. 2009 13:37:04
org.artofsolving.jodconverter.office.OfficeProcess start
INFO: started process
23 sept. 2009 13:37:12
org.artofsolving.jodconverter.office.OfficeConnection connect
INFO: connected: 'socket,host=127.0.0.1,port=2002,tcpNoDelay=1'
loading CSL Besondere Bedingungen
...<snip> filling doc</snip>
writing /var/folders/yD/yDMRSGr92RWjfE+8ZM3lcU+++TI/-Tmp-/
planes991065454/CSL Besondere Bedingungen_gen.pdf
writing /var/folders/yD/yDMRSGr92RWjfE+8ZM3lcU+++TI/-Tmp-/
planes991065454/CSL Besondere Bedingungen_gen.doc
finished CSL Besondere Bedingungen
closing doc
loading BV Sicherungsschein mit Zuschlag
23 sept. 2009 13:37:39
org.artofsolving.jodconverter.office.OfficeConnection$1 disposing
INFO: disconnected: 'socket,host=127.0.0.1,port=2002,tcpNoDelay=1'
23 sept. 2009 13:37:39
org.artofsolving.jodconverter.office.PooledOfficeManager$1
disconnected
ATTENTION: connection lost unexpectedly; attempting restart
23 sept. 2009 13:37:39
org.artofsolving.jodconverter.office.ProcessPoolOfficeManager stop
INFO: stopping
23 sept. 2009 13:37:39
org.artofsolving.jodconverter.office.ManagedOfficeProcess
doEnsureProcessExited
INFO: process exited with code 80
23 sept. 2009 13:37:39
org.artofsolving.jodconverter.office.OfficeProcess start
INFO: starting process with acceptString
'socket,host=127.0.0.1,port=2002,tcpNoDelay=1' and profileDir '/var/
folders/yD/yDMRSGr92RWjfE+8ZM3lcU+++TI/-
Tmp-/.jodconverter_socket_host-127.0.0.1_port-2002'
23 sept. 2009 13:37:40
org.artofsolving.jodconverter.office.OfficeProcess start
INFO: started process
23 sept. 2009 13:37:54
org.artofsolving.jodconverter.office.OfficeConnection connect
INFO: connected: 'socket,host=127.0.0.1,port=2002,tcpNoDelay=1'
23 sept. 2009 13:37:54
org.artofsolving.jodconverter.office.OfficeConnection$1 disposing
INFO: disconnected: 'socket,host=127.0.0.1,port=2002,tcpNoDelay=1'
23 sept. 2009 13:37:54
org.artofsolving.jodconverter.office.ManagedOfficeProcess
doEnsureProcessExited
INFO: process exited with code 0
23 sept. 2009 13:37:54
org.artofsolving.jodconverter.office.ProcessPoolOfficeManager stop
INFO: stopped
Exception in thread "main"
org.artofsolving.jodconverter.office.OfficeException: task failed
at org.artofsolving.jodconverter.office.PooledOfficeManager.execute
(PooledOfficeManager.java:97)
at
org.artofsolving.jodconverter.office.ProcessPoolOfficeManager.execute
(ProcessPoolOfficeManager.java:75)
at com.nraynaud.planes.output.OOConnector.generateDocs
(OOConnector.java:99)
at com.nraynaud.planes.output.OOConnector.generateDocs
(OOConnector.java:84)
at com.nraynaud.planes.output.OOConnector.main(OOConnector.java:58)
Caused by: java.util.concurrent.CancellationException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:230)
at java.util.concurrent.FutureTask.get(FutureTask.java:91)
at org.artofsolving.jodconverter.office.PooledOfficeManager.execute
(PooledOfficeManager.java:86)
... 4 more

it looks like in this case the connection was lost just after reading
the second document, before filling the first value, but it's random.

I post here, since it is asked to post here before posting on the
issue DB.

Mirko Nasato

unread,
Sep 23, 2009, 9:01:34 AM9/23/09
to jodcon...@googlegroups.com
I haven't looked at your issue in depth yet, but the 3.0 code is used
in a webapp that converts thousands of documents from multiple threads
each day without problems. A CancellationException usually occurs when
a document causes OOo to crash, so the task is cancelled and OOo
restarted, but this doesn't affect subsequent tasks.

Do you have some code for me to try and reproduce your issue? You can
send it to me privately if you prefer.

Kind regards

Mirko

2009/9/23 nraynaud <nray...@gmail.com>:

nraynaud

unread,
Sep 23, 2009, 9:50:01 AM9/23/09
to JODConverter
I think sending you 3000 lines of code wouldn't be easy for you to
work on. Moreover it's a random bug, often it simply works.

I've seen incidentally that you are the maven packager of the java OO
libraries, could you please push the sources jars in the central
repository ? It would help greatly when debugging this matter
(precisely the jurt souces I think).

Do you know if I can get some details on the XBridge closing event ?
In the debugger, I find no field of interest.

Thanks,

Nico

On 23 sep, 15:01, Mirko Nasato <mirko.nas...@gmail.com> wrote:
> I haven't looked at your issue in depth yet, but the 3.0 code is used
> in a webapp that converts thousands of documents from multiple threads
> each day without problems. A CancellationException usually occurs when
> a document causes OOo to crash, so the task is cancelled and OOo
> restarted, but this doesn't affect subsequent tasks.
>
> Do you have some code for me to try and reproduce your issue? You can
> send it to me privately if you prefer.
>
> Kind regards
>
> Mirko
>
> 2009/9/23 nraynaud <nrayn...@gmail.com>:

Mirko Nasato

unread,
Sep 23, 2009, 3:55:58 PM9/23/09
to jodcon...@googlegroups.com
Hi Nico,

2009/9/23 nraynaud <nray...@gmail.com>:


>
> I think sending you 3000 lines of code wouldn't be easy for you to
> work on. Moreover it's a random bug, often it simply works.
>

Well maybe you could extract a small part of that code just to
reproduce the issue.

> I've seen incidentally that you are the maven packager of the java OO
> libraries, could you please push the sources jars in the central
> repository ? It would help greatly when debugging this matter
> (precisely the jurt souces I think).
>

I did have a quick look at packaging the sources, but... I couldn't
find all the sources! I think the code for ridl.jar is generated from
IDL files or something like that. So I didn't bother. But if you want
to have a look and point me in the right direction I'll be glad to
give it another try.

> Do you know if I can get some details on the XBridge closing event ?
> In the debugger, I find no field of interest.
>

Not that I am aware of, unfortunately.

Kind regards

Mirko

nraynaud

unread,
Sep 24, 2009, 7:42:18 AM9/24/09
to JODConverter
Hi Mirko,

On 23 sep, 21:55, Mirko Nasato <mirko.nas...@gmail.com> wrote:
> Hi Nico,
>
> Well maybe you could extract a small part of that code just to
> reproduce the issue.

I will keep that at a last resort, for now the code is quite tangled.

> I did have a quick look at packaging the sources, but... I couldn't
> find all the sources! I think the code for ridl.jar is generated from
> IDL files or something like that. So I didn't bother. But if you want
> to have a look and point me in the right direction I'll be glad to
> give it another try.

I'll wil try to do that, if I manage to do it, I'll send you the magic
formula. I will try with jurt for now.
I propose an exchange : I package the jurt sources, and you release
jodconverter (even as a beta) on the maven repo.

Regards,

Nico.

nraynaud

unread,
Sep 25, 2009, 8:56:42 AM9/25/09
to JODConverter
Hi,

After a lot of time spent on it, I can't even compile OpenOffice.org
(the OpenOffice_3_1_1 tag) at all, so I think I will live with this
problem for now.

thanks for your answers.

Nico.

nraynaud

unread,
Oct 21, 2009, 5:32:47 PM10/21/09
to JODConverter
Hi Mirko,
I was in openoffice code for another reason, and I remembered this
topic.

here is a little script to download, arrange for maven and package the
jurt sources :
-------------8<-------------8<------------
#!/bin/sh

#curl -L http://download.services.openoffice.org/files/stable/3.1.1/OOo_3.1.1_src_core.tar.bz2
| bzip2 -cd | tar xf -
cd OOO310_m19/jurt
mkdir -p maven/src/main/java/
cp -r com maven/src/main/java/
cp -r ../ridljar/source/unoloader/com maven/src/main/java/
cd maven
curl -L http://mirrors.ibiblio.org/pub/mirrors/maven2/org/openoffice/jurt/3.1.0/jurt-3.1.0.pom
> pom.xml
mvn source:jar javadoc:jar package
-------------8<-------------8<------------

and then you can deploy the jars into the repository.

Regards,

Nicolas.

On 23 sep, 21:55, Mirko Nasato <mirko.nas...@gmail.com> wrote:
> Hi Nico,
>
> 2009/9/23 nraynaud <nrayn...@gmail.com>:

Mirko Nasato

unread,
Oct 26, 2009, 9:14:07 AM10/26/09
to jodcon...@googlegroups.com
Hi Nicolas,

Thanks, but as I mentioned before it's not that easy. Try and compare
the classes in ridl.jar with the *.java files in ridljar/ and you'll
see what I mean.

Kind regards

Mirko

2009/10/21 nraynaud <nray...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages