Apache OpenOffice (AOO) Bugzilla – Issue 81738
Java to OO server Disposed Connection issue
Last modified: 2013-02-24 21:10:15 UTC
Hi, I am using java code to remotely connect to Open Office Server for generating documents.I am using Open Office 2.1. Initially everything works fine. But after few rounds fo testing suddenly I encounter a DisposedConnectionException and my connection to Open Office server fails .The documents stop generating. java.lang.RuntimeException: java_remote_bridge (com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge@377c7bd7).sendReque st - is disposed at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest (java_remote_bridge.java:858) at com.sun.star.lib.uno.environments.java.Proxy.invoke(Proxy.java:141) But using telnet I can see that the Open Office server is up and running. Only the connection between my Appserver(where the Java code is written to connect to OO) and OO server is failing. Can you suggest whether its a code problem or configuration issue? This is the code to get OO connection : - protected static XComponent newDocComponentFromTemplate(String loadUrl) throws java.lang.Exception { L // get the remote service manager XMultiComponentFactory mxRemoteServiceManager = getRemoteServiceManager (unoUrl); Object desktop = mxRemoteServiceManager.createInstanceWithContext ("com.sun.star.frame.Desktop", mxRemoteContext); XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop); // define load properties according to com.sun.star.document.MediaDescriptor // the boolean property AsTemplate tells the office to create a new document // from the given file PropertyValue[] loadProps = new PropertyValue[2]; loadProps[0] = new PropertyValue(); loadProps[0].Name = "AsTemplate"; loadProps[0].Value = new Boolean(true); loadProps[1] = new PropertyValue(); loadProps[1].Name = "Hidden"; loadProps[1].Value = new Boolean(true); return xComponentLoader.loadComponentFromURL(loadUrl, "_blank", 0, loadProps); } Thanks and Regards Atul Ganeriwala
Framework issue.
@ atulganeriwala: Please use an OOo version that is newer than 2.1! OOo 2.3 has been released meanwhile! Please add information what platform you are using. @ sg: Please have a look.
Hi, The Application Server is WAS 5.1.1 on Linux machine. The Open Office Server(version 2.1) is remotely located on a windows 2000 machine. I would like to state one more observation related to this issue - Restarting of the WAS server again establishes a successful connection between OO and WAS. But it might again throw the same DisposedConnectionException after few days like before. In the code the OO connection objects are properly colsed so there can be no open connections as well. Can you suggest the reason for this problem ? Can you confirm that the latest version of Open Office.i.e. 2.3 will resolve this issue of DisposedConnectionException that occurs randomly sometimes. Thanks for your last response Atul
Hi, Any updates on this issue? Thanks Atul
accepted, but I have to look further into it.
This is a P3 issue - not really P2.
I cannot really reproduce the issue. What does the getRemoteServiceManager(unoUrl) function really do. When restarting your client resolves the issue, my guess is still that some resource on client side is not released somehow.
Cannot reproduce.
Closing the issue. If there are any updates on this, please notify me.
I encounter a issue like this. My application connect to OpenOffice 2.4.0 to convert some files among MS Office Document, RTF and OpenOffice Document. It does work fine initially, but it doesn't work now. The Exception like this: com.sun.star.lang.DisposedException: java_remote_bridge com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge@6f67c6fd is disposed at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.checkDisposed(java_remote_bridge.java:720) at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:639) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:159) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:136) at $Proxy6.queryInterface(Unknown Source) at com.sun.star.uno.UnoRuntime.queryInterface(UnoRuntime.java:159) at com.sun.star.uno.UnoRuntime.queryInterface(UnoRuntime.java:186) Here is the relative code as below: public class OpenOfficeDocumentConverter extends AbstractOpenOfficeDocumentConverter { // private static final Logger logger = LoggerFactory.getLogger(OpenOfficeDocumentConverter.class); public OpenOfficeDocumentConverter(OPConnection connection) { super(connection); } public OpenOfficeDocumentConverter(OPConnection connection, DocumentFormatRegistry formatRegistry) { super(connection, formatRegistry); } /** * In this file-based implementation, streams are emulated using temporary files. */ protected void convertInternal(InputStream inputStream, DocumentFormat inputFormat, OutputStream outputStream, DocumentFormat outputFormat) throws Exception{ File inputFile = null; File outputFile = null; try { inputFile = File.createTempFile("document", "." + inputFormat.getFileExtension()); //$NON-NLS-1$ //$NON-NLS-2$ OutputStream inputFileStream = null; try { inputFileStream = new FileOutputStream(inputFile); IOUtils.copy(inputStream, inputFileStream); } finally { IOUtils.closeQuietly(inputFileStream); } outputFile = File.createTempFile("document", "." + outputFormat.getFileExtension()); //$NON-NLS-1$ //$NON-NLS-2$ convert(inputFile, inputFormat, outputFile, outputFormat); InputStream outputFileStream = null; try { outputFileStream = new FileInputStream(outputFile); IOUtils.copy(outputFileStream, outputStream); } finally { IOUtils.closeQuietly(outputFileStream); } } catch (IOException ioException) { throw new OPException(Messages.getString("OpenOfficeDocumentConverter.4"), ioException); //$NON-NLS-1$ } finally { if (inputFile != null) { inputFile.delete(); } if (outputFile != null) { outputFile.delete(); } } } @SuppressWarnings("unchecked") //$NON-NLS-1$ protected void convertInternal(File inputFile, DocumentFormat inputFormat, File outputFile, DocumentFormat outputFormat) throws Exception { Map/*<String,Object>*/ loadProperties = new HashMap(); loadProperties.putAll(getDefaultLoadProperties()); loadProperties.putAll(inputFormat.getImportOptions()); Map/*<String,Object>*/ storeProperties = outputFormat.getExportOptions(inputFormat.getFamily()); synchronized (openOfficeConnection) { XFileIdentifierConverter fileContentProvider = openOfficeConnection.getFileContentProvider(); String inputUrl = fileContentProvider.getFileURLFromSystemPath("", inputFile.getAbsolutePath()); //$NON-NLS-1$ String outputUrl = fileContentProvider.getFileURLFromSystemPath("", outputFile.getAbsolutePath()); //$NON-NLS-1$ loadAndExport(inputUrl, loadProperties, outputUrl, storeProperties); } } @SuppressWarnings("unchecked") //$NON-NLS-1$ private void loadAndExport(String inputUrl, Map/*<String,Object>*/ loadProperties, String outputUrl, Map/*<String,Object>*/ storeProperties) throws Exception { XComponent document; document = loadDocument(inputUrl, loadProperties); if (document == null) { throw new OPException(Messages.getString("OpenOfficeDocumentConverter.9")); //$NON-NLS-1$ } refreshDocument(document); storeDocument(document, outputUrl, storeProperties); } @SuppressWarnings("unchecked") //$NON-NLS-1$ private XComponent loadDocument(String inputUrl, Map loadProperties) throws com.sun.star.io.IOException, IllegalArgumentException { XComponentLoader desktop = openOfficeConnection.getDesktopObject(); return desktop.loadComponentFromURL(inputUrl, "_blank", 0, toPropertyValues(loadProperties)); //$NON-NLS-1$ } @SuppressWarnings("unchecked") //$NON-NLS-1$ private void storeDocument(XComponent document, String outputUrl, Map storeProperties) throws com.sun.star.io.IOException { try { XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, document); storable.storeToURL(outputUrl, toPropertyValues(storeProperties)); } finally { XCloseable closeable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, document); if (closeable != null) { try { closeable.close(true); } catch (CloseVetoException closeVetoException) { if(net.heartsome.common.Constants.DEBUG_MODE){ closeVetoException.printStackTrace(); } } } else { document.dispose(); } } } } In addition, This code does work fine on the another computer. Could you suggest whether its a code problem or configuration issue?