|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
OOoBean and XDesktop::terminate()Hi,
I'm currently trying to get OO Documents embedded into a JFrame. Mainly working with examples from the developers Guide such as OOoBeanViewer.java . I encountered the problem, that I'm not able to correctly terminate my OO process through the XDesktop interface. Neither with the example given in OOoBeanViewer.java nor with self-made closing routines. The source code for terminating in the example looks like this: private void terminate() { setVisible(false); com.sun.star.frame.XDesktop xDesktop = null; try { xDesktop = aBean.getOOoDesktop(); } catch (com.sun.star.comp.beans.NoConnectionException aExc) { } // ignore aBean.stopOOoConnection(); stop(); if (xDesktop != null) xDesktop.terminate(); System.exit(0); } I'm always getting a DisposedException Error. If I move aBean.stopOOoConnection() down further, after xDesktop.terminate(), no exception arises anymore. But the processes soffice.bin and soffice.exe are still running. By searching the web I found several approaches to this problem. (Killing the office process programatically, trying to close with XComponent::dispose() -- didn't work, starting in headless mode etc. etc.) Most of them were ugly workarounds and they were from 2.x . On this mailing list was once the same question but it was back in 2004 ( http://markmail.org/message/ostlb4xtc6axzqah ) and the answer was to use XDesktop::terminate(). But as already stated it's not working for me at the moment. Am I'm doing sth. wrong here or is it a bug that appeared in 3.x? I'm using OOo 3.1.1(OOO310m19 Build9420), Java 1.5_017 and Windows XP. Any advice/info would be great. Regards, Steffen Börsig --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: OOoBean and XDesktop::terminate()Hi Steffen,
stopOOoConnection disposed all OO objects including the bridge to the remote office. It's not surprising that you get the DisposedException. There is currently no clean way to shutdown the office process from the bean. Even if it would work the XDesktop.terminate() is an ugly way to do it and can have unexpected side effects. You can try OOoBean.clear() which keeps the connection alive. But i assume that is doesn't work either. I haven't tested it. Terminating the office this way can have unexpected side effects if you don't work with different user installations ... It's indeed not optimal and it would be really nice to have a clean and controlled way to terminate the office or at least to trigger a termination if the bean would be the last client of the office process. Juergen Steffen Boersig wrote: > Hi, > > I'm currently trying to get OO Documents embedded into a JFrame. Mainly > working with examples from the developers Guide such as > OOoBeanViewer.java . > I encountered the problem, that I'm not able to correctly terminate my > OO process through the XDesktop interface. Neither with the example > given in OOoBeanViewer.java nor with self-made closing routines. > The source code for terminating in the example looks like this: > > private void terminate() > { > setVisible(false); > com.sun.star.frame.XDesktop xDesktop = null; > try > { > xDesktop = aBean.getOOoDesktop(); > } > catch (com.sun.star.comp.beans.NoConnectionException aExc) > { > } // ignore > aBean.stopOOoConnection(); > stop(); > if (xDesktop != null) > xDesktop.terminate(); > System.exit(0); > } > > I'm always getting a DisposedException Error. If I move > aBean.stopOOoConnection() down further, after xDesktop.terminate(), no > exception arises anymore. But the processes soffice.bin and soffice.exe > are still running. > By searching the web I found several approaches to this problem. > (Killing the office process programatically, trying to close with > XComponent::dispose() -- didn't work, starting in headless mode etc. etc.) > > Most of them were ugly workarounds and they were from 2.x . > > On this mailing list was once the same question but it was back in 2004 > ( http://markmail.org/message/ostlb4xtc6axzqah ) and the answer was to > use XDesktop::terminate(). But as already stated it's not working for me > at the moment. Am I'm doing sth. wrong here or is it a bug that appeared > in 3.x? > > I'm using OOo 3.1.1(OOO310m19 Build9420), Java 1.5_017 and Windows XP. > > Any advice/info would be great. > > Regards, > Steffen Börsig > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@... > For additional commands, e-mail: dev-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: OOoBean and XDesktop::terminate()>I'm always getting a DisposedException Error. If I move
>aBean.stopOOoConnection() down further, after xDesktop.terminate(), no >exception arises anymore. But the processes soffice.bin and soffice.exe >are still running. Sadly, I haveto use a bash script to do this. This one is configured for Linux Redhat/Centos to run from cron (you can change the binary paths for other distros). Specifically, this is will kill soffice.bin binaries left over from a web application that converts word docs to HTML. The process takes well under a minute, so a 10 minute buffer is safe, after 25 minutes, stubborn processes are sent the SIGKILL signal. Luckily, the 'parent' OpenOffice processes are owned by the root user in my case. If the processes you need to kill are the same ownership as the 'parent' OpenOffice processes you will need to add an extra step to the pipe. (filtering out commands with 'ServiceManager' might to the trick) It requires the 'procfs' virtual file system so it couldn't be ported to WinXX, you would need another solution under Windows. However, just about any other OS supports procfs so this could probably be easily ported to Solaris etc... Change PUSER, PMATCH, MINUTES and KMINUTES to suit your needs, then add this to cron. --Dave #!/bin/bash # this script is meant to be called regularly from cron and # will kill old OpenOffice processes owned by tomcat # owner of the processes to kill PUSER=tomcat # grep match of processes PMATCH='soffice\.bin' # minutes to send normal termination signal MINUTES=10 # for hung processes, minutes to wait before sending KILL signal KMINUTES=25 # normal termination /usr/bin/find /proc/ \ -maxdepth 3 \ -name 'cmdline' \ -user ${PUSER} \ -mmin +${MINUTES} \ -exec /bin/grep -l ${PMATCH} {} \; | \ /bin/cut -d'/' -f3 | \ /usr/bin/xargs -n1 -i^ /bin/bash -c '/bin/kill ^ 2>&1 > /dev/null' # wait a little longer then KILL hung processes /usr/bin/find /proc/ \ -maxdepth 3 \ -name 'cmdline' \ -user ${PUSER} \ -mmin +${KMINUTES} \ -exec /bin/grep -l ${PMATCH} {} \; | \ /bin/cut -d'/' -f3 | \ /usr/bin/xargs -n1 -i^ /bin/bash -c '/bin/kill -9 ^ 2>&1 > /dev/null' |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |