tanalyw General User

Joined: 22 Jan 2009 Posts: 9
|
Posted: Tue Feb 10, 2009 7:23 pm Post subject: Error in bootstrap when called at servlet |
|
|
Hi,
I have a problem with initialize my bootstrap. When I tried to run my conversion method at weblogic, i get DisposedException. any help? need it urgently. THanks.
Error received:
com.sun.star.lang.DisposedException: java_remote_bridge com.sun.star.lib.uno.bri
dges.java_remote.java_remote_bridge@350c13 is disposed
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.checkDisp
osed(java_remote_bridge.java:720)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendReque
st(java_remote_bridge.java:639)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendInter
nalRequest(java_remote_bridge.java:687)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.getInstan
ce(java_remote_bridge.java:587)
at com.sun.star.comp.urlresolver.UrlResolver$_UrlResolver.resolve(UrlRes
olver.java:140)
at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:292)
at saf.joint.opsum.action.OpenOfficeConversion.convert(OpenOfficeConvers
ion.java:2
at jsp_servlet.__exportopenoffice._jspService(__exportopenoffice.java:13
7)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:526)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:348)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispat
cherImpl.java:330)
at org.apache.struts.chain.commands.servlet.PerformForward.handleAsForwa
rd(PerformForward.java:99)
at org.apache.struts.chain.commands.servlet.PerformForward.perform(Perfo
rmForward.java:82)
at org.apache.struts.chain.commands.AbstractPerformForward.execute(Abstr
actPerformForward.java:51)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionComm
andBase.java:4
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.
java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(Composable
RequestProcessor.java:280)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:185
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:459)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
121)
My conversion codes:
public class OpenOfficeConversion {
private static XComponentContext componentContext = null;
//Method to convert OpenOffice document to html and vice versa
public static void convert(String inputFile, String conversionType)
{
System.out.println("TESTest");
try {
System.out.println("ININIINI");
//Connect or start a OpenOffice instance
componentContext = Bootstrap.bootstrap();
System.out.println("Cc: " + componentContext);
//Retrieve the OO desktop object
XMultiComponentFactory multiComponentFactory = componentContext.getServiceManager();
System.out.println("XMulit: " + multiComponentFactory);
Object desktop = multiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", componentContext);
System.out.println("desktop: " + desktop);
//Retrieve loader for loading input file
XComponentLoader componentLoader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, desktop);
//Set the properties for the input file
PropertyValue[] inputProperties = new PropertyValue[1];
inputProperties[0] = new PropertyValue();
inputProperties[0].Name = "Hidden";
inputProperties[0].Value = new Boolean(true); //to open document and show user use "false"
//Load the input file
XComponent component = componentLoader.loadComponentFromURL(createUNOFileURL(inputFile), "_blank", 0, inputProperties);
//Retrieve storer for storing output file
XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, component);
//Set the properties for the output file
PropertyValue[] outputProperties = new PropertyValue[2];
outputProperties[0] = new PropertyValue();
outputProperties[0].Name = "Overwrite";
outputProperties[0].Value = new Boolean(true);
outputProperties[1] = new PropertyValue();
outputProperties[1].Name = "FilterName";
outputProperties[1].Value = conversionType;
//retrieve the outputFile location
String outputFile = generateOutputFilePath(inputFile, conversionType);
//Create and Store the output file
storable.storeToURL(createUNOFileURL(outputFile), outputProperties);
System.out.println("Converted");
}
catch(Exception e){e.printStackTrace();}
}
//Generate the output file path
private static String generateOutputFilePath(String inputFileLocation, String conversionType)
{
.... return path;
}
//create the UNO file URL to create the outputFile
private static String createUNOFileURL(String fileLocation)
{
File newFile = new File(fileLocation);
URL url = null;
try {
url = newFile.toURL();
}
catch (MalformedURLException e) {
System.out.println(e);
}
// Create a URL, which can be used by UNO
String UNOFileURL = ExternalUriReferenceTranslator.create(componentContext).translateToInternal(url.toExternalForm());
if (UNOFileURL.length() == 0 && fileLocation.length() > 0) {
System.out.println("File URL conversion faild. Filelocation " + "contains illegal characters: " + fileLocation);
}
return UNOFileURL;
}
} |
|