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

Urgent help required......Facing some connection problem

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
saurabh_2411
General User
General User


Joined: 10 May 2009
Posts: 7

PostPosted: Fri May 15, 2009 6:11 am    Post subject: Urgent help required......Facing some connection problem Reply with quote

Hi

I am facing some problems while connecting to the openoffice.
Following are the s/w specifications

java 1.5.0_12
OpenOffice1.1.4
OS:LINUX

My code is invoking a custom method named 'initialize connection'. The body of this method is as shown

Code:

private void initializeConnection() throws Exception {
connection = openOfficeConnect;
// Getting the given type to convert to
stringConvertType = openOfficeConvertType;
// Getting the given extension that should be appended to the origin document
stringExtension = "sxw";

XComponentContext xComponentContext =
com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);

XMultiComponentFactory xMultiComponentFactory =
xComponentContext.getServiceManager();



Object objectUrlResolver =
xMultiComponentFactory.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",xComponentContext);

// Create a new url resolver
XUnoUrlResolver xurlresolver =
(XUnoUrlResolver) UnoRuntime.queryInterface(XUnoUrlResolver.class,objectUrlResolver);

// Resolves an object that is specified as follow:
// uno:<connection description>;<protocol description>;<initial object name>
System.out.println(
      "connecting to openoffice " + connection);
      Object objectInitial = xurlresolver.resolve(connection);

// Create a service manager from the initial object
xMultiComponentFactory = (XMultiComponentFactory) UnoRuntime.queryInterface(
   XMultiComponentFactory.class,objectInitial);

// Query for the XPropertySet interface.
XPropertySet xpropertysetMultiComponentFactory =
   (XPropertySet) UnoRuntime.queryInterface(
         XPropertySet.class,xMultiComponentFactory);

// Get the default context from the office server.
Object objectDefaultContext =
      xpropertysetMultiComponentFactory.getPropertyValue(
            "DefaultContext");

// Query for the interface XComponentContext.
xComponentContext =
      (XComponentContext) UnoRuntime.queryInterface(
      XComponentContext.class,objectDefaultContext);

/* A desktop environment contains tasks with one or more
   frames in which components can be loaded. Desktop is the
   environment for components which can instanciate within
   frames. */
xcomponentloader =
      (XComponentLoader) UnoRuntime.queryInterface(
      XComponentLoader.class,
      xMultiComponentFactory.createInstanceWithContext(
         "com.sun.star.frame.Desktop",
                  xComponentContext));

//if get to here with no error, reset start attempts
connectAttempts = 0;
} catch (Exception e) {
   System.out.println(
      "Exception connecting to OpenOffice: Attempt ="
            + connectAttempts);
            e.printStackTrace();
         connectAttempts++;
      if (connectAttempts > 3) {
         throw new Exception(
            "Error running OpenOffice conversion",
            e);
         }


For starting the service the command line arguments are :
Code:

/usr/lib/ooo-1.1/program/soffice   -headless -nofirststartwizard -accept="socket,host=0,port=8100;urp;StarOffice.ServiceManager"


For Connecting to Openoffice
Code:

/usr/lib/ooo-1.1/program/soffice   -headless -nofirststartwizard -accept="socket,host=0,port=8100;urp;StarOffice.ServiceManager"


I am getting following exception
Code:

Starting OpenOffice /usr/lib/ooo-1.1/program/soffice   -headless -nofirststartwizard -accept="socket,host=0,port=8100;urp;StarOffice.ServiceManager"
connecting to openoffice uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager;
service manager created
value is null
Exception connecting to OpenOffice: Attempt =0
java.lang.NullPointerException
        at com.hcl.OpenOfficeConverter.initializeConnection(OpenOfficeCoverter.java:341)
        at com.hcl.OpenOfficeConverter.createInstanceIfNeeded(OpenOfficeCoverter.java:164)
        at com.hcl.OpenOfficeConverter.getInstance(OpenOfficeCoverter.java:239)
        at com.hcl.OpenOfficeConverter.process(OpenOfficeCoverter.java:487)
        at com.hcl.OpenOfficeConverter.main(OpenOfficeCoverter.java:462)


So far i have debugged the code and come to a conclusion that the xpropertysetMultiComponentFactory is coming out to be null...

Following are the things that I have already tried:::::

1)I have made all necessary changes required for display thing i.e
a) Xvfb :5 -screen 0 800x600x16 &
b) ooffice -invisible -nologo -display :5
2) tried with host=localhost & host=0 & host=127.0.0.1
3)installed new version of openofficeorg(3.0.1) and change the classpath with new libraries which are in basic3.0/program/classes :-still facing the above excpetion
4)tried connecting to openoffice installed on windows2003 server by providing the server ip.

But in vain... still um facing that null pointer excpetion...... Please help in this regard...... that is the on;ly cure for my headache as deliverables are near.....


Thanks
SB
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API 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