openoffice.org - Connect XPage with OpenOffice -
i have button on xpage want connect remote openoffice instance. openoffice started , listening socket connection.
the onclick event of button runs following ssjs:
oo = new com.test.openoffice(); oo.init("host=127.0.0.1,port=8107"); oo.openfile("c:\\temp\\test.odt");
the code raises excepction jva.lang.illeagalstateexception: notescontext not initialized thread
the exception raised within method init
of class openoffice
.
the relevant parts of class openoffice following code:
public class dhopenoffice implements serializable { private static final long serialversionuid = -7443191805456329135l; private xcomponentcontext xremotecontext; private xmulticomponentfactory xmcf; private xtextdocument otextdocument; public dhopenoffice() { xremotecontext = null; xmcf = null; otextdocument = null; } public void init(string hostadr) throws java.lang.exception { xremotecontext = null; xcomponentcontext xlocalcontext = bootstrap.createinitialcomponentcontext(null); xunourlresolver xurlresolver = unourlresolver.create(xlocalcontext); string sconnect = "uno:socket," + hostadr + ",tcpnodelay=0;urp;staroffice.servicemanager"; object context = xurlresolver.resolve(sconnect); xremotecontext = unoruntime.queryinterface(xcomponentcontext.class, context); xmcf = xremotecontext.getservicemanager(); }
the code line object context = xurlresolver.resolve(sconnect);
1 raises exception.
why happing? reason exception , how can resolve situation?
n.b.: class code runs smoothly in standalone application. error occurs when code started ssjs code.
it looks threading issue. there number of things can go , try:
- wrap whole interaction custom class , use managed bean instead of calling ssjs
- make sure not hand on notes objects custom class, own
- check if open document toolkit sufficient operations interested in, don't need run oo
let know how goes
update
try outside standard xpages cycle. 1 way deploy custom plug-in servlet:
import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; public class openofficeservlet extends httpservlet { // code goes here }
you need plugin.xml right:
<?xml version="1.0" encoding="utf-8"?> <?eclipse version="3.4"?> <plugin> <extension point="org.eclipse.equinox.http.registry.servlets"> <servlet alias="/ooproxy" class="com.yourcompany.openofficeservlet" /> </extension> </plugin>
then e.g. post json structure or serializable java object servlet data , process there (async if necessary). deploy such plug-in using updatesite.nsf
Comments
Post a Comment