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

URL seems to be Unsupported in loadComponentFromURL

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


Joined: 30 Jan 2008
Posts: 10

PostPosted: Fri Mar 07, 2008 1:16 pm    Post subject: URL seems to be Unsupported in loadComponentFromURL Reply with quote

Hi All,

I am trying to load a html document from a URL. Also I have lookked at this forum, I din't get any issues resolved like this.


Code:
XComponentContext xContext = Bootstrap.bootstrap();
XMultiComponentFactory xMultiComponentFactory = xContext.getServiceManager();
XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));

[b]String loadURL= http://localhost:8080/doc/abstract.html.[/b]

(XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));
propertyvalue[0] = new PropertyValue();
propertyvalue[0].Name = "Hidden";
propertyvalue[0].Value = new Boolean(true);
System.out.println("3");
Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(loadUrl, "_blank", 0, propertyvalue);

I am getting follwoing ERROR message::


com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one.
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedEx
ception(Job.java:187)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:153)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java
:349)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java
:318)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThr
eadPool.java:106)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendReque
st(java_remote_bridge.java:657)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request
(ProxyFactory.java:159)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(
ProxyFactory.java:141)
at $Proxy4.loadComponentFromURL(Unknown Source)
at gov.nasa.sbir.webservice.merge.MergeServiceSoapBindingImpl.convertHTM
LTOPDF(MergeServiceSoapBindingImpl.java:196)
at gov.nasa.sbir.webservice.merge.MergeServiceSoapBindingImpl.mergeFiles
(MergeServiceSoapBindingImpl.java:72)
at gov.nasa.sbir.webservice.merge.MergeServiceSoapBindingSkeleton.mergeF
iles(MergeServiceSoapBindingSkeleton.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)

[b]How this http://localhost:8080/doc/abstract.html URL will be resolved by loadComponentFromURL ?[/b]
Thanks in Advance
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Fri Mar 07, 2008 2:31 pm    Post subject: Re: URL seems to be Unsupported in loadComponentFromURL Reply with quote

hijam wrote:
I am trying to load a html document from a URL.

Which OOo version? Which operating system? Which programming language? BeanShell? Pasting the code to a Java class gave me a lot of errors.

hijam wrote:
Code:
XComponentContext xContext = Bootstrap.bootstrap();
XMultiComponentFactory xMultiComponentFactory = xContext.getServiceManager();
XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));

String loadURL= http://localhost:8080/doc/abstract.html.

(XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));
propertyvalue[0] = new PropertyValue();
propertyvalue[0].Name = "Hidden";
propertyvalue[0].Value = new Boolean(true);
System.out.println("3");
Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(loadUrl, "_blank", 0, propertyvalue);

Posting code like this is a bad idea. Surround it with
Code:
[code] and [/code]
and it is much better to read for others (see working example below).

hijam wrote:
I am getting follwoing ERROR message::
com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one.
...
How this http://localhost:8080/doc/abstract.html URL will be resolved by loadComponentFromURL ?

Pasting the code to a Java class gave me a lot of errors. And the reason for your problem: You assign to loadURL the link "http://localhost:8080/doc/abstract.html". But in "loadComponentFromURL()" you access loadUrl. Another bad idea Wink

The following code example works on Windows XP with OOo 2.3.1 and Java 6:
Code:
import com.sun.star.beans.PropertyValue;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.comp.helper.BootstrapException;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;

public class URLUnsupported {

    public static void main(String[] args) throws BootstrapException, Exception {

        XComponentContext xContext = Bootstrap.bootstrap();
        XMultiComponentFactory xMultiComponentFactory = xContext.getServiceManager();
        XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));

        String loadURL = "http://static.springframework.org/spring/docs/2.5.x/reference/introduction.html";

        PropertyValue[] propertyvalue = new PropertyValue[1];
        propertyvalue[0] = new PropertyValue();
        propertyvalue[0].Name = "Hidden";
        propertyvalue[0].Value = new Boolean(true);
        System.out.println("3");
        Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(loadURL, "_blank", 0, propertyvalue);
    }
}
Back to top
View user's profile Send private message
hijam
General User
General User


Joined: 30 Jan 2008
Posts: 10

PostPosted: Sat Mar 08, 2008 7:54 am    Post subject: New Error remoteUnoRequestRaisedException Reply with quote

Thanks a Lot for your Replay.

Now I am able to load the file, but I am getting error during storing the file after converting it to PDF Follwoign are the code:

[code]
private String convertHTMLTOPDF(){
String loadUrl = "http://localhost:8080/doc/abstract.html";
String storeUrl = "http://localhost:8080/doc/abstract.pdf";
System.out.println("path: "+path);
System.out.println("START HTML TO PDF CONVERSION");
try {
XComponentContext xContext = Bootstrap.bootstrap();
XMultiComponentFactory xMultiComponentFactory = xContext.getServiceManager();
XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));

PropertyValue propertyvalue[] = new PropertyValue[1];
// Setting the flag for hidding the open document
propertyvalue[0] = new PropertyValue();
propertyvalue[0].Name = "Hidden";
propertyvalue[0].Value = new Boolean(true);

Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(loadUrl, "_blank", 0, propertyvalue);//new PropertyValue[0]);

PropertyValue[] conversionProperties = new PropertyValue[1];
conversionProperties[0] = new PropertyValue();
conversionProperties[0].Name = "FilterName";
conversionProperties[0].Value = "writer_pdf_Export";

XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class,objectDocumentToStore);

xstorable.storeToURL(storeUrl,conversionProperties);

} catch (java.lang.Exception e) {
e.printStackTrace();
}
return storeUrl;
}
[/code]

After loading successfully I am trying to convert html file to PDF. Same code works if I am using like
[code]
storeURL="file:///D:/TESTPDF/OpenOfficeExample/abstract.pdf";
[/code]

But it is throwing error when I try to use
[code]
String storeUrl = "http://localhost:8080/doc/abstract.pdf";
[/code]

it's throwing following error:
[code]
com.sun.star.task.ErrorCodeIOException:
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:187)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:153)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:349)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:318)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:106)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:657)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:159)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:141)
at $Proxy5.storeToURL(Unknown Source)
[/code]

Thanks in advance.
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Sat Mar 08, 2008 8:10 am    Post subject: Re: New Error remoteUnoRequestRaisedException Reply with quote

hijam wrote:
Now I am able to load the file, but I am getting error during storing the file after converting it to PDF Follwoign are the code:

Code:
      PropertyValue[] conversionProperties = new PropertyValue[1];
      conversionProperties[0] = new PropertyValue();
      conversionProperties[0].Name = "FilterName";
      conversionProperties[0].Value = "writer_pdf_Export";


After loading successfully I am trying to convert html file to PDF. Same code works if I am using like
Code:
storeURL="file:///D:/TESTPDF/OpenOfficeExample/abstract.pdf";


But it is throwing error when I try to use
Code:
String storeUrl = "http://localhost:8080/doc/abstract.pdf";


it's throwing following error:
Code:
com.sun.star.task.ErrorCodeIOException:

Exactly this problem has been discussed here: http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=1149

Conclusion of that thread: If you load a HTML file, OOo opens it as Web Writer document (which you cannot see, because you open the document hidden). For that reason you have to use "writer_web_pdf_Export" as "FilterName" for storing the file.
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