Using the PostGISService with geotools 2.3.0-M1 and java 1.5
I get exceptions calling the methods findService and find.
java.lang.IllegalArgumentException: URI is not absolute
at java.net.URI.toURL(URI.java:1080)
at org.geotools.catalog.defaults.DefaultCatalog.find
(DefaultCatalog.java:178)
at com.hazlorealidad.geo.GeoCatalog.main(GeoCatalog.java:209)
This is due to the PostGISService not creating an absolute URI,
(no protocol is present).
The "Fix" I came up with was to extend the PostGISService give it a
protocol
public class ExtendedPostGISService extends PostGISService
{
public ExtendedPostGISService(Catalog parent, Map params) {
super(parent, params);
}
public URI getIdentifier() {
URI uri=super.getIdentifier();
try {
return new URI( "postgis", uri.getHost(), uri.getPath(),
uri.getFragment());
}
catch (URISyntaxException e) {
//should not happen
return uri;
}
}
}
but now we need to define a protocol handler for postgis
package com.hazlorealidad.geo.postgis;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
public class Handler extends URLStreamHandler
{
public Handler()
{
super();
}
@Override
protected URLConnection openConnection(URL u) throws IOException
{
return null;
}
}
and putting the line
System.setProperty
("java.protocol.handler.pkgs","com.hazlorealidad.geo");
to the main class
Im not sure if its the best solution, youre welcome to use any of the
code as you see fit.
Andy Bailey
Hazlorealidad.com
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel