OpenOffice sample TextReplace throws BootstrapException
Harsha Ravnikar <[email protected]>
| Newsgroups | gmane.comp.openoffice.devel.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am trying out OpenOffice example "TextReplace" available from the
following URL:
http://wiki.services.openoffice.org/wiki/API/Samples/Java/Writer/TextReplace
I am also using bootstrapconnector.jar available from
http://user.services.openoffice.org/en/forum/viewtopic.php?t=2520
While executing it, I get the following exception:
com.sun.star.comp.helper.BootstrapException
at
ooo.connector.BootstrapConnector.connect(BootstrapConnector.java:129)
at
ooo.connector.BootstrapSocketConnector.connect(BootstrapSocketConnector.java:68)
at
ooo.connector.BootstrapSocketConnector.connect(BootstrapSocketConnector.java:45)
at
ooo.connector.BootstrapSocketConnector.bootstrap(BootstrapSocketConnector.java:82)
at
org.openoffice.sdk.example.text.TextReplace.getDesktop(TextReplace.java:175)
at
org.openoffice.sdk.example.text.TextReplace.main(TextReplace.java:63)
I have pasted below the full method thats corresponds to
BootstrapConnector.java:129. Exception occurs when the statement
oooServer.start(oooAcceptOption);is executed. The exception occurs
even when OpenOffice write is running. Can
anyone let me know how to resolve this issue?
==========================================================================
*BootstrapConnector.java
*
public XComponentContext connect(String oooAcceptOption, String
oooConnectionString) throws BootstrapException {
this.oooConnectionString = oooConnectionString;
XComponentContext xContext = null;
try {
// get local context
XComponentContext xLocalContext = getLocalContext();
oooServer.start(oooAcceptOption);
// initial service manager
XMultiComponentFactory xLocalServiceManager =
xLocalContext.getServiceManager();
if ( xLocalServiceManager == null )
throw new BootstrapException("no initial service manager!");
// create a URL resolver
XUnoUrlResolver xUrlResolver =
UnoUrlResolver.create(xLocalContext);
// wait until office is started
for (int i = 0;; ++i) {
try {
xContext = getRemoteContext(xUrlResolver);
break;
} catch ( com.sun.star.connection.NoConnectException ex ) {
// Wait 500 ms, then try to connect again, but do not
wait
// longer than 5 min (= 600 * 500 ms) total:
if (i == 600) {
throw new BootstrapException(ex.toString());
}
Thread.sleep(500);
}
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.lang.Exception e) {
throw new BootstrapException(e); //Line 129
}
return xContext;
}
==========================================================================
Regards,
Harsha