OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Problems connecting: DisposedException .. "Connection R

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> Setup and Troubleshooting
View previous topic :: View next topic  
Author Message
plainkeyman
Newbie
Newbie


Joined: 23 Nov 2004
Posts: 1

PostPosted: Tue Nov 23, 2004 6:19 pm    Post subject: Problems connecting: DisposedException .. "Connection R Reply with quote

i am running slackware linux with java 1.4.2_05, open office 1.1.3.

here is my code:

Code:

import com.sun.star.bridge.XUnoUrlResolver;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.beans.XPropertySet;

public class FirstConnection extends java.lang.Object {
    private XComponentContext xRemoteContext = null;
    private XMultiComponentFactory xRemoteServiceManager = null;
   
    public static void main(String[] args) {
        FirstConnection firstConnection1 = new FirstConnection();
        try {
            firstConnection1.useConnection();
        }
        catch (java.lang.Exception e) {
            e.printStackTrace();
        }
    }
   
    protected void useConnection() throws java.lang.Exception {
        try {
            xRemoteServiceManager = this.getRemoteServiceManager("uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager");
            String available = (null != xRemoteServiceManager ? "available" : "not available");
            System.out.println("remote ServiceManager is " + available);
        }
        catch (com.sun.star.connection.NoConnectException e) {
                System.err.println("No process listening on the resource");
                e.printStackTrace();
                throw e;
        }
         catch (com.sun.star.lang.DisposedException e) { //works from Patch 1
            xRemoteContext = null;
            throw e;
        }         
    }
   
    protected XMultiComponentFactory getRemoteServiceManager(String unoUrl) throws java.lang.Exception {
        if (xRemoteContext == null) {
         
         System.out.println("1");
            XComponentContext xLocalContext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
         
         System.out.println(2);
            XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
         
         System.out.println(3);
            Object urlResolver  = xLocalServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", xLocalContext);
         
            // query XUnoUrlResolver interface from urlResolver object
         System.out.println(4);
            XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface(XUnoUrlResolver.class, urlResolver);
         
         System.out.println(5);
            // Second step: use xUrlResolver interface to import the remote StarOffice.ServiceManager,
            // retrieve its property DefaultContext and get the remote servicemanager
            Object initialObject = xUnoUrlResolver.resolve(unoUrl);
         
         System.out.println(6);
            XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, initialObject);
         
         System.out.println(7);
            Object context = xPropertySet.getPropertyValue("DefaultContext");
         
         System.out.println(8);           
            xRemoteContext = (XComponentContext)UnoRuntime.queryInterface(XComponentContext.class, context);
        }
        return xRemoteContext.getServiceManager();
    }
}


it prints out 1..2..3..4..5.. and then
a DisposedException .. "Connection Reset" message


any ideas??
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> Setup and Troubleshooting All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group