URL seems to be an unsupported one

Creating a macro - Writing a Script - Using the API

URL seems to be an unsupported one

Postby mattaspen » Fri May 02, 2008 10:26 pm


I spent a good part of my day trying to get the example "FirstLoadComponent.java" to work.

System: linux, CentOs 5

In March, I was able to get this example to run and refactored it into a mini application. At the time, I was using OO 2.3.1.
In April, I upgraded to OO 2.4.0 and, have returned to my project, but kept getting the error:

com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one.

So, I revisited the 'examples' directory and started on trying to get "FirstLoadComponent.java" working as my 1st step.
The error/result was the same. The error happens on line 116 line:

Code: Select all   Expand viewCollapse view
XComponent xSpreadsheetComponent = xComponentLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, loadProps);

I searched Google and the forums and the only post that I found that is remotely related to my problem is http://www.mail-archive.com/dev@udk.openoffice.org/msg00600.html, which states:

See http://api.openoffice.org/docs/common/r ... lator.html and http://api.openoffice.org/docs/common/r ... ToInternal. In short, OOo distinguishes between "internal" and "external" URIs, where Java's URIs are external, so code like

String path2 = com.sun.star.uri.ExternalUriReferenceTranslator.
if (path2.length() == 0 && path.length() != 0) {
throw new RuntimeException();

is needed to translate path into path2 before using it. (And that it worked in OOo 1.3 was by chance, not by design.)

So, I spent some time trying all of the possible combinations from this post (as well as hard-coding the various "url" possibilities (on linux as "internal" and "external")), but still kept getting the same error.

Since this example originally worked (as I stated above) in OO 2.3.1, I uninstalled 2.4.0 and re-installed 2.3.1.

Unfortunately, I keep getting the same error.

To my knowledge, nothing has changed on my box; as far as settings etc.

My question, then, is: what am I doing wrong and what is/are a possible solution(s)?

Posts: 5
Joined: Thu Apr 17, 2008 5:53 pm

Re: URL seems to be an unsupported one

Postby acknak » Fri May 02, 2008 10:55 pm

Moved to Macros & UNO API.
AOO4/LO5 • Linux • Fedora 23
User avatar
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: URL seems to be an unsupported one

Postby mathew » Thu May 08, 2008 12:27 pm

Not sure if I understand your problem, but I'm wondering if you are having a problem with Java's encoding of URLs.

I use this method to hack the uri returned by URI.toString()
Code: Select all   Expand viewCollapse view
   * The {@link java.net.URI#toString()} method has a broken handling of file protocol.
   * The returned string starts file:/, when it should start file:///.
   * @see http://mindprod.com/jgloss/uri.html
   * @see http://forum.java.sun.com/thread.jspa?forumID=31&threadID=671284
  public static String uriToString (URI uri) {
    String s = uri.toString ();
    if ("file".equals (uri.getScheme ())) {
      return "file://" + s.substring (5);
    else {
      return s;
Sourceforge projects using OpenOffice: asas & hubung
Posts: 7
Joined: Sat Apr 19, 2008 3:04 am

Re: URL seems to be an unsupported one

Postby reparker2000 » Wed Dec 03, 2008 10:50 pm

I had the same error, and after staring at the URL awhile, I realized that I was using a filename that had blanks in it. If you're using an OS/filesystem which requires such a pathname or filename which has special characters in it to be quoted -- surrounded by double-quotes -- then your URL will fail unless you surround at least the portion which has special charactes in it with double-quotes...or you can change the special characters to "non-special" characters. For example, I changed my blanks to underscores, and the URL no longer failed.
Posts: 1
Joined: Wed Dec 03, 2008 10:38 pm

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 10 guests