Issue 81738 - Java to OO server Disposed Connection issue
Summary: Java to OO server Disposed Connection issue
Status: CLOSED IRREPRODUCIBLE
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: steffen.grund
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-19 11:24 UTC by atulganeriwala
Modified: 2013-02-24 21:10 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description atulganeriwala 2007-09-19 11:24:51 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
Comment 1 michael.ruess 2007-09-19 12:13:34 UTC
Framework issue.
Comment 2 Olaf Felka 2007-09-19 13:48:14 UTC
@ 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.
Comment 3 atulganeriwala 2007-09-20 06:18:03 UTC
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
Comment 4 atulganeriwala 2007-09-25 07:16:13 UTC
Hi,

Any updates on this issue?

Thanks
Atul
Comment 5 steffen.grund 2007-10-31 16:18:09 UTC
accepted, but I have to look further into it.
Comment 6 steffen.grund 2007-10-31 16:25:56 UTC
This is a P3 issue - not really P2.
Comment 7 steffen.grund 2007-11-06 14:38:38 UTC
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.
Comment 8 steffen.grund 2007-12-03 10:53:10 UTC
Cannot reproduce.
Comment 9 steffen.grund 2007-12-03 10:53:38 UTC
Closing the issue. If there are any updates on this, please notify me.
Comment 10 setve007 2009-03-31 09:37:54 UTC
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?