[api-dev] 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 ^ 21 /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 ^ 21 /dev/null' - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Re: OOoBean
On Wed, 19 Jan 2005 20:40:32 +0100 Jochen Staerk [EMAIL PROTECTED] wrote: Hi, I always thought that adding the class path to your manifest would be sufficient and has the same effect than using the cp-commandline switch but I could be completely mistaken. I thought a MANIFEST like this would work: --8-- Manifest-Version: 1.0 Main-Class: at/bestsolution/oeush/members/MembersAdmin Class-Path: lib/a.jar /usr/lib/openoffice/program/classes/officebean.jar ... 1) I'm not sure I'm right either, today was the first time I learned about how to add classpaths to manifests but 2) AFAIK manifest-classpaths can be relative and CLASSPATHs are absolute. And with a manifest very similar to yours (adding jurt and juh.jar and stuff) I get a libofficebean.so not-found-exception. bye, Jochen Hi Jochen, normally if you have the oo-jars (all from oo-home/program/classes) in your classpath (manifest or CLASSPATH or with the -cp switch) the libraries are found. There is a helüper-class, which load the native-libraries in the parent-directory of officebean.jar (if the library is not in LD_LIBRARY_PATH or %PATH% on Windows). If you want to deploy your application together with the oo-jars (in a relative subdirectory) the native-libraries cannot be found. If I understand you correct and you want to deploy your application (some mails above on this list) on different systems and OS. You have to find a way to set the correct-classpath and native-ölibrary-path on the target system. You can use start-scripts (run.bat run.sh) which create a classpath and launch your application with java -cüüp mypath my.package.Main. But the users have to set the OO-path by hand before. In this case you cannot use a selfstarting jar. You can use a classloader to load your application. There you can use a selfstarting jar (double-click on Windows). There are some launcher-projects available like: http://jakarta.apache.org/commons/launcher/ You can develop your own Launcher and add the oo-jars from the target-system to your application. Example: create a subdirectory 'lib' of your application and add there all your application-jars. In the parent-directory place the launcher-class or self-starting jar like(untested): import java.io.*; import java.net.*; import java.util.*; public class Launcher{ public Launcher(){ } public static void main(String[] args){ Launcher l = new Launcher(); l.launchApplication(args); } public launchApplication(String[] args){ ArrayList urls = new ArrayList(); //add your application jars addJars(urls,lib); //get now the path of the OO-installation //from a property-file, dialog or scan the filesystem String oopath = get...(); //add all to the classpath addJars(urls,oopath); //create URL[] from the urls-List URL[] classpath ... URLClassLoader loader = new URLClassLoader(classpath); //now load your application Main-class and start this try{ Class clazz = loader.loadClass(my.Main); //get the main-method Class[] params = new Class[1]; params[0] = args.getClass(); Method m = clazz.getDeclaredMethod(main,params); //prepare the args Object[] methodparams = new Object[1]; //the args from the commandline methodparams[0] = args; //lauch the application m.invoke(null,methodparams); }catch(Exception e){ //handle this } } private void addJars(List list,String dir){ File f = new File(dir); if(f.isDirectory()){ File[] jars = f.listFiles(); for(int i=0;ijars.length;i++){ if(jars[i].getName().toLowerCase().endsWith(.jar)){ try{ list.add(jars[i].toURI().toURL(); }catch(Excpetion e){ //handle this } } } } } } This will launch your application with custom-classloader, which puts the oo-jars to his classpath. On the windows-platform you will get problems if the oo-home/program directory is not int the %PATH%. You can preload the native-libs, but you need the right order of the libs and this can simple changed by newer OO-releases. I hope this can help. Best Regards, Simon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Re: OOoBean
Hi Simon, and thanks for your answer and the classloader-sample-code, normally if you have the oo-jars (all from oo-home/program/classes) in your classpath (manifest or CLASSPATH or with the -cp switch) the libraries are found. There is a helüper-class, which load the If you want to deploy your application together with the oo-jars (in a relative subdirectory) the native-libraries cannot be found. OK If I understand you correct and you want to deploy your application (some mails above on this list) on different systems and OS. You have to find a way to set the correct-classpath and native-ölibrary-path on the target system. OK. That's what I want to do; deploy my application (if possible as a single java JAR) to users which use different OSses and have their OOs in different locations. I do not need to have officebean.jar in my JAR, but I'll explain why that would have helped in the next paragraph. I won't do it, anyway, because this obviously is not the way it's ment to be. You can use start-scripts (run.bat run.sh) which create a classpath and launch your application with java -cüüp mypath my.package.Main. But the users have to set the OO-path by hand before. In this case you cannot use a selfstarting jar. OK. Additionally, I can not use a selfstarting JAR if I do not have a classloader or a launcher application that changes the JAR-Manifest according to the user's OO-location because a java -jar-Application won't react on the -cp-Argument nor or the CLASSPATH-environment. (http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html, The JAR archive specified by the -jar option, which overrides all other values. If this option is used, all user classes come from the specified archive.) You can develop your own Launcher and add the oo-jars from the target-system to your application. Example: ... On the windows-platform you will get problems if the oo-home/program directory is not int the %PATH%. You can preload the native-libs, but you need the right order of the libs and this can simple changed by newer OO-releases. Do you mean this order can change in a newer OO-release or this problem can be resolved by using a newer OO-release? I hope this can help. very much, thank you - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Re: OOoBean
Hi Simon, I mean the order can changed by newer releases. The officebean.dll depends on MSVCR70, UWINAPI, sal3, jpipe (this is the order to load it). But this can be changed with OO2.0 or 1.1.x. I have not looked at OO2.0 and I don't know if the new OfficeBean will handle this self, Yes, OOoBean (the new Java Bean baseclasss for OOo) does load these libraries. But if you translate it yourself with a new compiler, other libraries might be needed. Michael - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]