I know, the bootstrap-method-problems are discussed very often, but I have not found a solution for my problem.
following situation:
we have a web-application, implemented as JSPs on a JETTY-Server (Win XP)(Linux should be supported too)
install-path of OOo 3: C:/fsales/OpenOffice.org3/ (without blank!)
a part of the jetty - configfile:
Code: Select all
wrapper.java.classpath.12=C:/fsales/OpenOffice.org3/URE/java/jurt.jar
wrapper.java.classpath.13=C:/fsales/OpenOffice.org3/Basis/program/classes/unoil.jar
wrapper.java.classpath.14=C:/fsales/OpenOffice.org3/URE/java/ridl.jar
wrapper.java.classpath.15=C:/fsales/OpenOffice.org3/URE/java/juh.jar
wrapper.java.classpath.16=C:/fsales/OpenOffice.org3/URE/java/bootstrapconnector.jar
wrapper.java.classpath.17=C:/fsales/OpenOffice.org3/program //prevents the "no executable found!"-exception
Code: Select all
INFO | jvm 1 | 2009/05/06 17:19:07 | com.sun.star.comp.helper.BootstrapException: com.sun.star.connection.NoConnectException
INFO | jvm 1 | 2009/05/06 17:19:07 | at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:297)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jsp.oo_005fintegration_005fvon_005fkunde_005ffill_005fcreate_jsp._jspService(org.apache.jsp.oo_005fintegration_005fvon_005fkunde_005ffill_005fcreate_jsp:270)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
INFO | jvm 1 | 2009/05/06 17:19:07 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
INFO | jvm 1 | 2009/05/06 17:19:07 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.servlet.Dispatcher.include(Dispatcher.java:192)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jsp.oo_005fintegration_005fvon_005fkunde_005ffill_jsp._jspService(org.apache.jsp.oo_005fintegration_005fvon_005fkunde_005ffill_jsp:182)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
INFO | jvm 1 | 2009/05/06 17:19:07 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
INFO | jvm 1 | 2009/05/06 17:19:07 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1074)
INFO | jvm 1 | 2009/05/06 17:19:07 | at filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:170)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.Server.handle(Server.java:285)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:751)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:500)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
INFO | jvm 1 | 2009/05/06 17:19:07 | at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
Code: Select all
mxRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
as said: it worked with OOo 2
here the lines of code (concerning OOo) of this JSP
Code: Select all
<%@page import="com.sun.star.awt.Point"%>
<%@page import="com.sun.star.awt.Size"%>
<%@page import="com.sun.star.awt.FontWeight"%>
<%@page import="com.sun.star.beans.PropertyState"%>
<%@page import="com.sun.star.beans.PropertyValue"%>
<%@page import="com.sun.star.beans.XPropertySet"%>
<%@page import="com.sun.star.beans.XPropertyState"%>
<%@page import="com.sun.star.bridge.XUnoUrlResolver"%>
<%@page import="com.sun.star.comp.servicemanager.ServiceManager"%>
<%@page import="com.sun.star.connection.*"%>
<%@page import="com.sun.star.frame.*"%>
<%@page import="com.sun.star.container.*"%>
<%@page import="com.sun.star.drawing.*"%>
<%@page import="com.sun.star.lang.*"%>
<%@page import="com.sun.star.style.*"%>
<%@page import="com.sun.star.table.XCell"%>
<%@page import="com.sun.star.text.*"%>
<%@page import="com.sun.star.uno.*"%>
<%@page import="com.sun.star.util.XRefreshable"%>
<%@page import="com.sun.star.view.XPrintable"%>
<%
System.out.println("Start opening Office-Connection");
try {
XComponentContext mxRemoteContext = null;
XMultiComponentFactory mxRemoteServiceManager = null;
System.out.println("Create Hashtable with DataBaseComponents");
Hashtable recipient = new Hashtable();
/* filling hashtable .... */
System.out.println("Hashtable created");
// load template with User fields and bookmark
java.io.File sourceFile = new java.io.File(application.getRealPath("/") +"/oo_vorlagen/kunde/" + request.getParameter("file"));
StringBuffer sTemplateFileUrl = new StringBuffer("file:///");
sTemplateFileUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
if (mxRemoteContext == null && mxRemoteServiceManager == null) {
// get the remote office context. If necessary a new office
// process is started
System.out.println("try to connect to a running office");
//String oooExeFolder = "C:\\fsales\\OpenOffice/program";
//mxRemoteContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
mxRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
mxRemoteServiceManager = mxRemoteContext.getServiceManager();
String available = (mxRemoteServiceManager != null ? "available" : "not available");
System.out.println("remote ServiceManager is " + available);
}
mxRemoteServiceManager = mxRemoteServiceManager;
// retrieve the Desktop object, we need its XComponentLoader
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[1] = new PropertyValue();
loadProps[0].Value = new Boolean(true);
loadProps[1].Name = "Hidden";
loadProps[1].Value = new Boolean(false);
// load
System.out.println("Load file: " + sTemplateFileUrl.toString());
XComponent xTemplateComponent = xComponentLoader.loadComponentFromURL(sTemplateFileUrl.toString(), "_blank", 0, loadProps);
System.out.println("Office Document opened:" + sTemplateFileUrl.toString());
// get XTextFieldsSupplier, XBookmarksSupplier interfaces
XTextFieldsSupplier xTextFieldsSupplier = (XTextFieldsSupplier)
UnoRuntime.queryInterface(XTextFieldsSupplier.class,
xTemplateComponent);
XBookmarksSupplier xBookmarksSupplier = (XBookmarksSupplier)
UnoRuntime.queryInterface(XBookmarksSupplier.class, xTemplateComponent);
// access the TextFields and the TextFieldMasters collections
XNameAccess xNamedFieldMasters = xTextFieldsSupplier.getTextFieldMasters();
XEnumerationAccess xEnumeratedFields = xTextFieldsSupplier.getTextFields();
// iterate over hashtable and insert values into field masters
java.util.Enumeration keys = recipient.keys();
while(keys.hasMoreElements()) {
// get column name
String key = (String)keys.nextElement();
// access corresponding field master Try to put the DB-Values
try {
Object fieldMaster = xNamedFieldMasters.getByName(
"com.sun.star.text.FieldMaster.User." + key);
// query the XPropertySet interface, we need to set the Content property
XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, fieldMaster);
// insert the column value into field master
xPropertySet.setPropertyValue("Content", recipient.get(key));
} catch (java.lang.Exception e) {
// System.out.println("DB-Column: " + key + " not in Office-Form");
}
}
// afterwards we must refresh the textfields collection
XRefreshable xRefreshable = (XRefreshable)UnoRuntime.queryInterface(
XRefreshable.class, xEnumeratedFields);
xRefreshable.refresh();
java.io.File targetFile = new java.io.File(application.getRealPath("/") +"/kontakt_anhaenge/" + koknr + ".pdf");
StringBuffer sStoreFileUrl = new StringBuffer("file:///");
sStoreFileUrl.append(targetFile.getCanonicalPath().replace('\\', '/'));
XComponent xDoc=xTemplateComponent;
String storeUrl = sStoreFileUrl.toString();
XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class, xDoc);
XFrame xFrame = xModel.getCurrentController().getFrame();
xFrame.activate();
XStorable xStorable = (XStorable)UnoRuntime.queryInterface(
XStorable.class, xDoc);
// PropertyValue[] storeProps = new PropertyValue[1];
PropertyValue[] props = new PropertyValue[2];
props[0] = new PropertyValue();
props[0].Name = "FilterName";
props[0].Value = "writer_pdf_Export";
props[1] = new PropertyValue();
props[1].Name = "CompressionMode";
props[1].Value = "1";
System.out.println("... store \"" + koknr + ".pdf\" .");
xStorable.storeToURL(storeUrl, props);//storeProps);
xTemplateComponent.dispose();
does anyone have an idea?
greetings from austria
lenaz